peckadesign / pd-naja

1 stars 0 forks source link

Allow popstate event to propagate #3

Closed zipper closed 1 year ago

zipper commented 1 year ago

When non-modal state has been retrieved, event.stopImmediatePropagation() has been called. That caused non related popstate handlers from other extension or third party scripts not be run. This call was originally added to prevent extra request when closing the modal opened with snippet cache off. It is now handled with different approach - when closing the modal, we set a flag shouldPreventSnippetFetch and based on this flag, we call event.preventDefault() inside FetchEvent handler.

Also when snippet cache was off, the modalOpener and modalOptions were not properly set in options (should be retrieved from state), which might have caused errors. Now those properties are also set when they should be.

BREAKING CHANGE: AjaxModal interface changed, show method argument opener is always of type Element. pdModal inside history state is only present when modal is opened (should be used internally only anyway).