Fix destroying dialog that destroys itself when closing
authorMatthias Schmidt <gravatronics@live.com>
Thu, 7 May 2020 18:23:52 +0000 (20:23 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 7 May 2020 18:23:52 +0000 (20:23 +0200)
Close #3292

wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js

index b8cfe360dd5ce9bd037b244e10272d1706e78aae..453cd6895418b0dad47436c034686305062246ec 100644 (file)
@@ -893,8 +893,13 @@ define(
                                        this.close(id);
                                }
                                
-                               elRemove(_dialogs.get(id).dialog);
-                               _dialogs.delete(id);
+                               // If the dialog is destroyed in the close callback, this method is
+                               // called twice resulting in `_dialogs.get(id)` being undefined for
+                               // the initial call.
+                               if (_dialogs.has(id)) {
+                                       elRemove(_dialogs.get(id).dialog);
+                                       _dialogs.delete(id);
+                               }
                                _dialogObjects.delete(callbackObject);
                        }
                },