You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried add this modifier to a modal in our app. The modal is supposed to close if a user clicks outside the main content region. It's closing the modal when it shouldn't:
Click inside the modal to highlight some text
Drag the cursor slightly past the edge of the modal content
Lift the mouse button
This behavior should not be considered an outside click. To check whether this behavior is intentional, try clicking your mouse anywhere on a webpage, dragging your cursor on top of an interactive element such as a button or a link, and then release the cursor. The browser does not behave as though you just clicked on that button.
Possible solution:
Before I knew that this library even existed, I built our own outside click handling for our modal and had to deal with this very problem. It involves adding mousedown and mouseover listeners for the target area, and also adding mousedown and mouseup listeners for the entire document. Those events update a state object to track whether the mouse was ever clicked down on the target area or dragged over the target area. If either of those answers is "Yes", it doesn't fire the callback.
Here's the code I implemented for a standalone modifier. I tried looking through your source code, but I haven't digested it well enough to feel confident that I could create a PR and not break any of your work.
The text was updated successfully, but these errors were encountered:
zelaznik
changed the title
False positive when a user highlights text inside the modal and drags into the outside region
False positive when a user highlights text inside the modal and drags cursor outside
Mar 4, 2021
Summary:
I tried add this modifier to a modal in our app. The modal is supposed to close if a user clicks outside the main content region. It's closing the modal when it shouldn't:
This behavior should not be considered an outside click. To check whether this behavior is intentional, try clicking your mouse anywhere on a webpage, dragging your cursor on top of an interactive element such as a button or a link, and then release the cursor. The browser does not behave as though you just clicked on that button.
Possible solution:
Before I knew that this library even existed, I built our own outside click handling for our modal and had to deal with this very problem. It involves adding
mousedown
andmouseover
listeners for the target area, and also addingmousedown
andmouseup
listeners for the entire document. Those events update a state object to track whether the mouse was ever clicked down on the target area or dragged over the target area. If either of those answers is "Yes", it doesn't fire the callback.Here's the code I implemented for a standalone modifier. I tried looking through your source code, but I haven't digested it well enough to feel confident that I could create a PR and not break any of your work.
The text was updated successfully, but these errors were encountered: