-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Focus is lost after selecting option from "Select Menu" dropdown #38169
Comments
Looks like what's happening is the toolbar re-renders when the nav block contents are replaced, causing the button that focus should be returned to to disappear from the DOM. |
FYI that this is being looked at in #38907 (comment). We decided not to fix in that PR as this Issue is too complex. |
Whoever works on a fix here should be sure to include an e2e test to ensure the |
I tested this by removing the |
This was a fairly complicated issue. I think this happens when the block changes in to loading state. I made a fix but it probably isn't pretty. Hopefully it may serve as a guide moving forward. I think this happens when the placeholder dynamically changes and focus is not forced. The block itself has some interesting focus issues even outside of this issue. 👎 |
@getdave That's not a very scientific test, because there can be more than one cause of a bug. That's exactly the case in the navigation block, lots of DOM elements are unmounted/remounted, and that's one cause. In a past attempt to solve this I removed as much code that causes unmounting/remounting as I could and the Recursion Provider was still an issue. |
I guess I didn't include my nuance here. What I meant to say was there doesn't appear to be a single cause here. |
Tested and is working fine! |
Description
In the Navigation Block toolbar, the "Select Menu" button opens a dropdown from where a different menu can be selected. Selecting a menu from that dropdown causes the dropdown to close, but when it closes keyboard focus is reset to the document body.
Focus should instead go back to the "Select Menu" button in the toolbar, or perhaps to the block itself.
Possibly due to #39044
Edit: Now it only happens when creating a new menu or importing from a classic one.
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: