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

[feature] When modal is rendered into a certain node, esc should close the modal when it's pressed within that node #62

Open
everdimension opened this issue Mar 28, 2018 · 7 comments

Comments

@everdimension
Copy link

This might be optional behavior. Perhaps even a separate option altogether.

Something like a rootNode prop, maybe?

@davidtheclark
Copy link
Owner

@everdimension: Can you please give a more concrete example of this use case?

@everdimension
Copy link
Author

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.

@davidtheclark
Copy link
Owner

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.

@everdimension
Copy link
Author

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.

@davidtheclark
Copy link
Owner

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?

@everdimension
Copy link
Author

Yeah, or better yet, we might just check inside the checkDocumentKeyDown handler whether the target is a child of the underlay.

@davidtheclark
Copy link
Owner

Yep, @everdimension, that sounds like a good plan. PR welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants