by MiPi » Tue Aug 29, 2023 2:46 am
Hello.
You should call your initialization inside init function of dialog, this function is called when window is completely loaded and prepared and all standard functions and elements are accessible.
Then you should use window.localListen instead of app.listen. MM sometimes reuses old hidden browser windows for new dialogs (a lot faster then creating always new window), closing dialog cleans window contents and during reopening it prepares new content and then calls init function. In case you would use app.listen, the listener is sometimes not removed during closing, and this can cause instabilities and problems later (it was not case in this situation, all controls like buttons automatically unlisten all listeners bound to them during their cleanup). Listeners created using window.localListen are always removed automatically during closing dialog, so it is more reliable for all situations, not dependent on other cleanup functions.
Anyway your main problem was caused by calling window.close(), this closes browser window, but does not clean "modal state" in MM app, so the main window remains inaccessible. For closing modal windows use closeWindow or assign value to modalResult, this will close window automatically too. Anyway thanks for reporting, we will look at it, so even window.close() will work, I think it worked in the past.
Hello.
You should call your initialization inside init function of dialog, this function is called when window is completely loaded and prepared and all standard functions and elements are accessible.
Then you should use window.localListen instead of app.listen. MM sometimes reuses old hidden browser windows for new dialogs (a lot faster then creating always new window), closing dialog cleans window contents and during reopening it prepares new content and then calls init function. In case you would use app.listen, the listener is sometimes not removed during closing, and this can cause instabilities and problems later (it was not case in this situation, all controls like buttons automatically unlisten all listeners bound to them during their cleanup). Listeners created using window.localListen are always removed automatically during closing dialog, so it is more reliable for all situations, not dependent on other cleanup functions.
Anyway your main problem was caused by calling window.close(), this closes browser window, but does not clean "modal state" in MM app, so the main window remains inaccessible. For closing modal windows use closeWindow or assign value to modalResult, this will close window automatically too. Anyway thanks for reporting, we will look at it, so even window.close() will work, I think it worked in the past.