-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Can't click ModalOverlay to close an open Combobox #5338
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
Comments
Doesn't matter if it's in the codesandbox iframe or not |
@snowystinger Hi, I happened to look at the code sandbox, and it seems like the root cause of the modal not closing is rather the improper usage of animation named 'fade' in See this sandbox: https://codesandbox.io/s/react-typescript-forked-g2vwx7?file=/src/styles.scss Screenshot![]() |
Thank you for having a look @sookmax. I'm not sure if your codesandbox wasn't saved, but I still see the issue. If I open the dialog, then open the combobox, then try to click on the underlay instead of the dialog, the combobox won't close. Seeing it on Chrome 118 MacOS 14 I'll double check that the keyframes are defined and uncommented appropriately in our docs |
I'm sorry that the link didn't work as expected for you.. I must have done something wrong to share the sandbox, but weirdly I'm perfectly fine with the link (even when I'm logged out of codesandbox). But if you keep having the issue with the sandbox I shared, you can go to the original sandbox and uncomment the keyframe 'fade' yourself, or conversely comment out 'fade' animation inside I'm also attaching a video recording from my end. modal_closing_issue.mp4 |
Ah, yes, sorry. I do see that you can dismiss the dialog by clicking the backdrop when the keyframes are uncommented. The original discussion/issue was about being able to close the Combobox, not the dialog.
So we'll still need to look into that because I see the same behavior in the original as in your sandbox. |
Oh wait.. no I'm the one who should be sorry here lol. I misunderstood the issue entirely 🤦♂️ I'll try to look into this on Monday and report back here if I manage to find anything useful or insightful! |
@snowystinger Hey, I think I've found something promising. Long story short.. so I was looking at the following code, and realized
And react-spectrum/packages/@react-aria/overlays/src/usePopover.ts Lines 76 to 85 in 6c61f5b
And react-spectrum/packages/react-aria-components/src/ComboBox.tsx Lines 190 to 196 in 6c61f5b
So the aforementioned condition I wondered what would happen if combobox_modal_closing_issue.movI hope this helps! |
Thanks so much for looking into that. My feeling, based on what you've found, is that blur is probably playing a role here. Comboboxes should close on blur. However, if we click something which cannot receive focus, then we do not blur, and therefore we do not close. I also noticed that we have the same issue in React Spectrum components https://codesandbox.io/s/react-typescript-forked-h7g3rd?file=/src/App.tsx which I find odd, because the other day when I created something similar for storybook, it actually closed both the combobox and the dialog. One last thing on the blur/focus. When I click inside the dialog, I do see that focus moves to the dialog. This can be seen using a tool such as NerdeFocus. I do think your observation about how isNonModal interacts with onInteractOutside is correct, and maybe we need to tease that apart a bit more. I think it's correct to use isNonModal, but maybe we are missing some nuance for useInteractOutside. I'll bring it up with the team but welcome any thoughts you have as well. |
You're right! My first intuition was to look for handlers that handle 'blur' event, though the 'onBlur' handlers I had found (from all over the place lol) didn't seem to execute if I clicked the
Sorry I'm probably missing something here, but then again, how come clicking on modal_bigger_than_dialog_720.mov
I wholeheartedly agree! Anyways, I'm looking forward to seeing the fix for this issue. I didn't know internal focus/blur mechanics were this complicated.. I really appreciate you guy's work on building react-aria 😄. |
#5684 (comment) is related. We may be able to do something with |
It seems that this react-spectrum/packages/@react-aria/overlays/src/useOverlay.ts Lines 148 to 151 in 1c6c4ad
I don't know what to do with this. The comment says that it fixes the Firefox behaviour. |
Perhaps? I'm a bit wary of exposing a |
I also see this behavior with |
Here's an example of the behavior with multiple Open a menu, click anywhere on the page (note the Popover doesn't close). |
Thanks for the additional examples! This all stems from
|
Discussed in #5337
Originally posted by elilabes November 1, 2023
I have modal that has a number of Comboboxes in them. I'd like to make it so that when you click anywhere not in the Combobox it closes the Combobox. Currently it seems, I have to click inside the modal content area to close the Combobox.
I am not sure if I am missing some documentation or if this is expected (i'd hope not, it is a real pain).
Here is a rough example using React Aria Components' demo. https://codesandbox.io/s/react-typescript-forked-2ly428?file=/src/App.tsx
The text was updated successfully, but these errors were encountered: