-
Notifications
You must be signed in to change notification settings - Fork 17
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
Close QR-modal on outside click #892
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this approach is that clicking inside the modal (e.g. on the QR code) also closes the modal, as "outside" is defined as "outside of ref
". And ref
is the share menu. So the whole modal overlay is outside.
I think I'd prefer it if the Modal
would take a prop closeOnOutsideClick
or something like that, which implements this logic inside Modal
. This should probably default to false
to not change the behavior of other modal uses.
Weird. There
TLDR: There is some issue I haven't figured out but don't spend too much if any time debugging (I already did). Marking this as a draft for now. |
ad206e4
to
198a27b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should keep or rather revert to that behaviour?
After testing it out, I think I like that it doesn't close on outside click for these confirmation modals. So I think the PR as is is good.
I investigated the escape thing. The problem is: the share menu does its own "open" state management and just passes open={state !== "closed"}
to the floating. And since the floating cannot affect the state in ShareButton
, nothing happens.
Since I already looked at it locally, I also implemented a fix: I added another prop to FloatingContainer
: onClose
. A function that is called when the floating container determines it wants to close. Will push in a sec.
Cool, thank you. I also narrowed it down to the "open" prop and made a fix (removing the "closed" state and using the Unfortunately this came with another issue that is also present in your fix: Using escape to close the QR modal also closes the share menu, which I'd really prefer to stay open. Floating UI seems to do it's own thing with the escape key and I'm out of ideas on how to fix that. |
Oh, I hope we didn't work in parallel all the time so that I wasted your work? But yeah, your approach is totally valid as well. I do think though that the "having the state management outside" use case will be inevitable in the future, so the
Yeah, I noticed this too. Honestly, I think it's fine. I also have no idea how to fix that and I don't think investing time is terribly useful as it's such a minor thing. |
Yeah I definitely agree, so let's merge this. |
This closes the modal when clicked outside, but keeps the share menu open.
Closes #879