Sweetalert2: TypeError: null is not an object (evaluating 'getModal().querySelectorAll')

Created on 4 May 2017  路  3Comments  路  Source: sweetalert2/sweetalert2

This error happened on Chrome Mobile iOS 57. The error was reported from one of the systems, that I take part in developing.

  1. The problem was that there was handleKeyDown function triggered (I think it there might be a virtual keyboard left open when on the iPhone) and then getFocusableElements

  2. Inside this function getModal method is called, which uses getContainer().querySelector(...).

This is where the error was thrown. The DOM element with class swalClasses.container was not found, therefore null is returned from the execution of the getContainer() method and getContainer().querySelector() is invalid.


I can not provide steps to reproduce, because I was not able to reproduce the error either


I think the right solution here is to handle not found container element in the getModal method. All the methods that use it must be updated accordingly to accept null as a result of the execution of getModal().

As I am not familiar with this lib, so I invite you to have a discussion before proceeding with PR :)

bug

Most helpful comment

I'm encountering the same problem in Chrome 58.0.3029.96 on macOS Sierra.

Able to reproduce it with this:

swal("test");
swal("test2");
swal.close();
// Then press escape

I'm guessing the problem is that the overwritten modal doesn't have its events unbound.

All 3 comments

I'm encountering the same problem in Chrome 58.0.3029.96 on macOS Sierra.

Able to reproduce it with this:

swal("test");
swal("test2");
swal.close();
// Then press escape

I'm guessing the problem is that the overwritten modal doesn't have its events unbound.

Thanks guys for such a good bug report! I'll handle it asap.

Fixed in v6.6.3

Thanks @dirchev and @brtinney-touchsuite for your help in debugging this issue!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

snsarma picture snsarma  路  3Comments

SasSam picture SasSam  路  3Comments

thelastinuit picture thelastinuit  路  3Comments

integrateddigital picture integrateddigital  路  4Comments

limonte picture limonte  路  3Comments