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: Ensure drag from within Modal does not accidentally dismiss it #1594

Merged
merged 1 commit into from
Sep 26, 2022

Conversation

philschanely
Copy link
Contributor

Description

Product teams discovered that when a user clicks and drags within a modal but releases outside the Modal, it is dismissed as if the full click happened outside the modal. This PR aims to address this behavior by listening for both mousedown and mouseup so as to ensure both happen in the dismiss area before triggering the dismiss action.

Screenshots

https://www.loom.com/share/4c29d75c753c4a119e7763e011d9677e

Testing in sage-lib

See http://localhost:4000/pages/component/modal?tab=preview
See http://localhost:4100/?path=/story/sage-modal--wired

Testing in kajabi-products

  1. (LOW) Adjusted Modal's dismiss click listener to be a combination of mousedown and mouseup. This allows us to be more precise to dismiss only when full click happens outside the modal. Fixes an issue where users inadvertently dismiss the modal if they click and drag within a modal (such as to select content in a form field) and release outside the modal.

Related

https://kajabi.atlassian.net/browse/DSS-94

@philschanely philschanely added the bug Something isn't working label Sep 19, 2022
@philschanely philschanely requested a review from a team September 19, 2022 19:16
@philschanely philschanely self-assigned this Sep 19, 2022
Copy link
Member

@pixelflips pixelflips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates seem to be working phenomenally. Nice work! 🔥

@pixelflips pixelflips requested a review from a team September 19, 2022 19:42
Copy link
Member

@teenwolfblitzer teenwolfblitzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM, nice work!

const handleMouseDown = (evt) => setMouseDownSrc(evt.target);

const handleMouseUp = (evt) => {
if (evt.target === evt.currentTarget && evt.target === mouseDownSrc) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@philschanely philschanely merged commit 75a12c9 into develop Sep 26, 2022
@philschanely philschanely mentioned this pull request Sep 26, 2022
@monicawheeler monicawheeler deleted the DSS-94/pjs-modal-drag-protection branch December 6, 2022 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants