-
Notifications
You must be signed in to change notification settings - Fork 4.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
Escape on Block Toolbar returns focus to Editor Canvas #55712
Merged
Merged
Commits on Nov 2, 2023
-
Move lastFocus into redux store
Stores the element that had last focus from the editor when focus leaves the editor canvas
Configuration menu - View commit details
-
Copy full SHA for 8123cc4 - Browse repository at this point
Copy the full SHA 8123cc4View commit details -
ForwardRef for selected block tools
Adding the escape keypress from the navigable block tools will require forwarding the ref from the BlockTools all the way down to the NavigableToolbar.
Configuration menu - View commit details
-
Copy full SHA for 3f5ceb3 - Browse repository at this point
Copy the full SHA 3f5ceb3View commit details -
Handle escape on toolbar via toolbar event listener
This method requires forwarding a ref from the editor level down to the navigable toolbar so that the escape unselect shortcut can be blocked and the navigable toolbar event listener will still fire. Blocking the global escape event shouldn't be necessary, but we have a combination of a few things all combining to create a situation where: - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element. - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it. Also, this is better than attaching it to all of the children in the block toolbar because when new items are attached to the toolbar (such as via the bubblesVirtually slots or the apply/cancel buttons when cropping an image) we can still catch the events. Otherwise, those buttons are added after the mount, and the children don't receive the listener.
Configuration menu - View commit details
-
Copy full SHA for e50fd49 - Browse repository at this point
Copy the full SHA e50fd49View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5718fdf - Browse repository at this point
Copy the full SHA 5718fdfView commit details -
Configuration menu - View commit details
-
Copy full SHA for dfc5f6d - Browse repository at this point
Copy the full SHA dfc5f6dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7eece08 - Browse repository at this point
Copy the full SHA 7eece08View commit details -
Remove onIndexChange from useEffect dependency array
I added it since it was passed in, but it is a callback and doesn't change. It was causing unnecssary rerenders that was messing with the focus position when selecting an item from a dropdown, such as when changing the heading level on a site title block.
Configuration menu - View commit details
-
Copy full SHA for ad87967 - Browse repository at this point
Copy the full SHA ad87967View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8558e69 - Browse repository at this point
Copy the full SHA 8558e69View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.