-
Notifications
You must be signed in to change notification settings - Fork 236
Description
Hi,
First, thanks a lot for this library!
Just wanted to report that 32140dd (released in 0.4.9
) introduced a major breaking change:
Screen.Recording.2021-12-12.at.16.19.01.mov
Note: I'm running the docs locally in this recording. You can't see it in the deployed version, which I assume is running an older version of Micromodal
.
🐛 What the issue is
The bug is in this onClick
method:
Line 138 (newly added) is the problem here, since most modals will follow the demo markup and look like this:
<div id="modal-1" aria-hidden="true">
<div class="modal__overlay" tabindex="-1" data-micromodal-close>
<div class="modal__container" role="dialog" aria-modal="true">
<!-- content -->
</div>
</div>
</div>
Any click event on the container (for example its padding, or between children elements) will effectively close the modal because the container's parent (e.target.parentNode
) is the overlay—which has the closeTrigger
.
Reproducing
- clone the repo
yarn
yarn lib:build
(make sure the latest lib is used by the docs)yarn docs:dev
(run the docs)- try to click the container, notice the bug
I'm happy to submit a PR to fix this, but I don't have context on why this change was applied in the first place1. Can we just remove this line? Or were you trying to fix something else with it?
Footnotes
-
The changelog says
🐞 BUGFIX Correctly closes modal when clicking on nested close elements
, which I don't really understand without context ↩