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

Dialogs:Esc key closed the two dialog #3280

Closed
meiguanxiHXX opened this issue Jan 14, 2019 · 4 comments
Closed

Dialogs:Esc key closed the two dialog #3280

meiguanxiHXX opened this issue Jan 14, 2019 · 4 comments

Comments

@meiguanxiHXX
Copy link

I had try put a new dialog in the dialog,I wish only close the new dialog when I fisrt press ESC key,maybe next press will close the old dialog. In fact, I did this it closed all dialog.
any help? thank you!

@tgreen7
Copy link
Contributor

tgreen7 commented Mar 10, 2019

@meiguanxiHXX You can add e.stopPropagation() to the inner dialog onClose so that the close event will not hit the outer dialog.

Check out this fiddle for an example: https://codesandbox.io/s/xll8q8v7mp

@tnrich
Copy link
Contributor

tnrich commented May 4, 2023

@tgreen7 what about if the inner dialog has canEscapeKeyClose={false} but the first dialog does not.. How do we stop propagation in that case?

Thanks in advance!

https://codesandbox.io/s/blueprintjs-playground-forked-pqqd74

@tnrich
Copy link
Contributor

tnrich commented May 4, 2023

@tgreen7 answering my own question - I think to do that means manually catching the esc key event and preventing dialog close:

https://codesandbox.io/s/blueprintjs-playground-forked-5onri8?file=/App.js

@adidahiya
Copy link
Contributor

I think you may be able to implement a "stop propagation" boundary for the inner Dialog with the new feature we just added to Portal & overlayable components: #6093 (to be released this week).

<Dialog stopPropagationEvents={["keyDown", "keyUp"]}>

(it's unlikely to be backported to Blueprint v3.x, though, as I see that's being used in @tnrich's code sandbox link)

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

4 participants