netgen-layouts / layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.
https://netgen.io/layouts
MIT License
36 stars 6 forks source link

Fix event being dispatched twice when canceling modal #26

Closed bcafuk closed 2 years ago

bcafuk commented 2 years ago

The cancel method would previously dispatch a cancel event and call the close method. The close method would then dispatch another cancel event. Thus, when calling the cancel method, two cancel events would end up dispatched, leading to event handlers being called twice.

This was observed in the "Add new policy" modal dialog, where canceling fires an HTTP request to discard a draft. The first request would discard the draft successfully, but the second would fail because the draft had already been discarded.

The cancel method always calls the close method and the close method always dispatches the event. Therefore, the cancel method does not need to dispatch the event itself, instead being able to rely on the close method to do it.

emodric commented 2 years ago

Thanks @bcafuk !