Skip to content
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

Modal window closes unexpectedly when 'mousedown' IN the modal and 'mouseup' on the background #287

Open
DimaGashko opened this issue Feb 3, 2020 · 8 comments
Labels
confirmed Bug is has been confirmed and is reproducible
Milestone

Comments

@DimaGashko
Copy link

Here's a video: https://drive.google.com/file/d/150mGwQNYmXyfykiVVdkw1VhCKvBhfQ96/view

This is small but really annoying issue!

p.s. the easiest solution is replace 'click' event by 'mousedown' (probably)

@piotrpog
Copy link

piotrpog commented Mar 9, 2020

+1 for this issue. Honestly, is there modal lib that gets that right?

Its really annoying if there is form in the modal, users often click form inputs and release mouse button outside modal which closes it!

@PeterDekkers
Copy link

Duplicate of #216

Worth mentioning that as a workaround you can disable clicking outside the modal to close by removing the data-micromodal-close attribute from the overlay.

I.e. change this:

<div class="modal__overlay" tabindex="-1" data-micromodal-close>

To this:

<div class="modal__overlay" tabindex="-1">

@PeterDekkers
Copy link

PeterDekkers commented May 1, 2020

Also my 2 cents regarding the suggested fix of using the mousedown event. I guess this should only be done for the overlay. In all other situations—e.g. close button—the click event would be correct.

So possibly this means that the overlay should have a new data-micromodal-alternate-close attribute or some-such that listens to mousedown events.

Happy to make a PR if that's useful.

@DimaGashko
Copy link
Author

DimaGashko commented May 1, 2020

@PeterDekkers yeah, removing data-micromodal-close is the solution sometimes, but I usually need that functionality too.

mousedown - probably, but it should be tested on mobile and other touch devices too

@PeterDekkers
Copy link

Yes indeed @DimaGashko, good point about touch devices.

@rmkane
Copy link

rmkane commented Jul 26, 2022

Any update on the status of this issue? Look like the close trigger is still shared among the close button and modal overlay.

@kalpeshsingh
Copy link
Collaborator

Hello folks!
I don't have bandwidth to work on this.

Please send PR if possible and @ghosh or I can merge it.

@dkniffin dkniffin added bug and removed bug labels Mar 21, 2025
@dkniffin
Copy link
Contributor

If anyone has time to make a PR for this, I'd be happy to review it. Otherwise, I'll get to it when I can.

@dkniffin dkniffin added the confirmed Bug is has been confirmed and is reproducible label Mar 21, 2025
@dkniffin dkniffin added this to the pre-1.0 milestone Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed Bug is has been confirmed and is reproducible
Projects
None yet
Development

No branches or pull requests

6 participants