-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix(Dialog): "esc" key close dialogs in wrong order #5021
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Ignored Deployments
|
in the Dialog.js we use the And there's an issue that I can't resolve on my own. Inside the This limitation prevents me from calling the proper I can't do any changes to the If you don't mind, I'd like to leave it to you and the core team to address this issue in the PR, as you have a better understanding of the situation with |
Good point let me look at that |
I think it should be |
I believe it uses the stopImmediatePropagation to ensure that once the "esc" key is handled, for example, by a modal, it prevents any other components, such as the sidebar, from also handling it. Same behavior could be achieved with |
Agreed its a better solution if you want to update. |
@melloware I think we need to add some code to identify the top most modal and return the execution from useOnEscapeKey -> handleEsc() if its not the top most modal.
But Identyfying the top most modal will be some good amount of work to do! |
@akshayantony55 in this PR I already written the code that identifies the topmost dialog (it will be the last dialog in And I didin't tested, but I feel like if another component (SideBar?) that uses useOnEscapeKey will be used together with Dialog - then handleEsc will not be triggered for one of them (either SideBar or Dialog, depending which one has assigned esc handler first). P.S.: or, if I understood you wrong and you propose to add |
@melloware I will spend some time on this during the weekend. |
I apologise, had busy week, so didn't had free time to look at the bug. I think I will be able to do that this weekend. @akshayantony55 please, inform if you already started doing something and had some progress |
Another PR for this issue was submitted: #5126 Please review and give thoughts? |
This task more complicated than I expected. I've added a commit with a basic concept for a possible implementation. Here's a rough overview:
Please note that this is a very rough concept, implemented for testing purposes. However, it has already resolved the issue with the Dialog component in the current implementation. Please, share your thoughts, and tell should I continue in this way, and apply the same approach to other components with "esc" handling or, probably, something should be done differently (or, probably, as bug fixed for Dialog we should stop at this point and then see how this solution will work "in production" before being applied everywhere) |
@avasuro I like where you are going with this. I agree we need some way of tracking across the different components if they are all subscribed to the document ESC key etc. |
Ready for review. Please test thoroughly as I haven't done extensive testing - just a basic check to ensure the "esc" key functions properly in all updated components. I've conducted a few tests involving multiple components. For example, making sure that if both the sidebar and dialog are open together, the modal closes on the first "esc" key press, and the sidebar closes on the second. |
I have also added PrimeTek on this review. This is great work. |
@melloware added |
@melloware added |
@avasuro i just merged some changes and there is a conflict as well as SpeedButton also just got close on esc! Appreciate you keeping up with these. |
@melloware merged |
Great job @avasuro |
Fix: #5019