react-aria-modal
react-aria-modal copied to clipboard
[feature] When modal is rendered into a certain node, `esc` should close the modal when it's pressed within that node
This might be optional behavior. Perhaps even a separate option altogether.
Something like a rootNode prop, maybe?
@everdimension: Can you please give a more concrete example of this use case?
What do you mean?
I just wish to optionally make it so that the esc press which originated outside the modal container wouldn't close the modal.
What do you mean?
I'm just trying to understand the use case here because it's not obvious to me.
How do you hit escape outside the modal — did you turn off the focus trap? If so, and it doesn't appear like a modal on top of everything, I'm wondering what the modal provides for you.
Use-case: application is integrated within another application, but not within an iframe.
In this case the modal will be on top of everything within the integrated app, but the surroundings might still be available and interactive. I didn't think about how focus trap would allow you to go outside, though. But maybe this should be allowed, too, if the user, say, clicks somewhere outside.
Ah, weird. I think it might be perfectly fine to attach the escape listener to the underlay instead of the document. That should solve things for you, right?
Yeah, or better yet, we might just check inside the checkDocumentKeyDown handler whether the target is a child of the underlay.
Yep, @everdimension, that sounds like a good plan. PR welcome.