-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
OnKeyDown in Modal #4987
Comments
Hello, |
Hello @NCBR, thank you for your submission. The issue was labeled "Status: Repro Missing", as you have not provided a way to reproduce the issue quickly. Most problems already solve themselves when isolated, but we would like you to provide us with a reproducible code to make it easier to investigate a possible bug. |
DataEntryModalExample.razor
@ code {
} DashboardModalExample.razor Open Modal @ code {
} When datagrid is in new/edit state here, it cancels. But if you put an onkeydown event for escape key on the datagrid that then cancels the line, and subsequently closes the entire modal, instead of only cancelling the line. |
Hello @NCBR Maybe try adding a flag to figure out if the row was already cancelled? Can you try something like this?
|
I tried your suggestion and it did work. Now the only problem is if I click out of the datagrid with my mouse (so I click anywhere on the modal), the modal doesn't seem to respond to escape being pressed. If I press escape while the datagrid is selected, it correctly cancels the row. I can then press escape again to close the modal. But if I click anywhere on the modal, it does not respond to escape until I select the datagrid again. Honestly not sure why it does that, or whether it's just on my end. |
Glad it worked. We'll let you know once we have news again. |
@David-Moreira, should we close this, or do you think we can add some extra logic to the codebase that handles this use case? |
We can take a look just to be sure. |
Hey, I've got a bit of an issue here
So I have a ModalService set up, that opens a custom component. That all works fine.
My issue is that when I have ANY OnKeyDown or OnKeyUp events in any of the child content, if escape is pressed it will close the modal. Without any OnKeyDown or OnKeyUp in the child content, pressing escape actually does nothing, doesn't even trigger the closing sequence.
I have an OnKeyDown on my datagrid, which I want to close the row editor if it is in Edit or New state when the Escape button is pressed. What happens instead is that the entire modal closes. I would like to be able to use stopPropagation so I can stop it from continuing out further, but that causes the website to become unresponsive (can't have two OnKeyDown).
I do still want to close the modal if Escape is pressed while not focusing the datagrid.
It seems to me that there is some issue with the handling of the closing sequence, as the modal closing sequence doesn't trigger for me without a OnKeyDown/OnKeyUp sequence present, whether it actually is meant to close it. Any old one will do apparently.
I know I can cancel the closing sequence, but that is also not going to solve my specific issue, as I still want it to close with Escape, just not by Escape being pressed while the datagrid is selected.
Edit: I may be able to provide some code snippets if needed, but due to it being a project for work I do have some limitations in what I can show.
The text was updated successfully, but these errors were encountered: