-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking change in 0.4.9: clicking the container closes the modal #490
Comments
See ghosh/Micromodal#490 for context.
Can confirm, having the same issue in 0.4.10. |
A workaround is adding extra wrapper between modal__overlay and modal__container. I did a search and the change was applied to fix this issue : Close button doesn't work when contains any elements. A simple solution could be to check if the parent hasn't the modal__overlay class. |
Yes, another wrapper was an obvious temporary solution, but it's kind of painful when a project has 100+ modals with different layout and design options. For now, I've just reverted back to 0.4.8 until there will be a fix. |
The work around of adding the extra div wrapper causes modal windows that need to scroll, to not scroll. |
@jclark-vh I'm not seeing the issue with scrolling, so I suspect that the issue is specific to your CSS. As long as the |
To fix this, I have changed the onClick event to only check event.target (not its parent) and also have placed the preventDefault and stopPropagation calls outside the if statement. like this:
This way the event will only fire when the user clicks on an element with the closeTrigger attribute. I honestly don't know why it was not done this way to begin with, hope I am not introducing new bugs to my site. |
Bummer that this broke in 0.4.10 but I solved it by creating a full size pseudo element over the child elements. Worked this time! |
See in #505 for a quick & simple fix 👍 |
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:Micromodal/lib/src/index.js
Lines 135 to 144 in a55c5fd
Line 138 (newly added) is the problem here, since most modals will follow the demo markup and look like this:
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 thecloseTrigger
.Reproducing
yarn
yarn lib:build
(make sure the latest lib is used by the docs)yarn docs:dev
(run the docs)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 ↩The text was updated successfully, but these errors were encountered: