-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix multiple tooltips showing on NavigableToolbars #49644
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
820035d
Add useKeyboardShortcut prop to NavigableToolbar and useToolbarFocus
jeryj 2c99327
Conditionally useKeyboardFocusShortcut in HeaderToolbar
jeryj 3db06db
Remove accidentally added line break
jeryj 87eabd8
Check all the conditions when a toolbar might be showing
jeryj b7e3091
Remove unnecesary line break
jeryj 9222cc6
Change logic to use isBlockWithToolbarSelected instead of isUnmodifie…
jeryj d4ed2ba
Start on e2e tests to cover various scenarios
jeryj c05a396
e2e test: should focus the top level toolbar when in select mode
jeryj 3146b4e
ede test: should focus the top level toolbar when on an empty block
jeryj ec44ad5
ede test: grouping into describe test sections
jeryj c201962
Scaffold top toolbar mode e2e tests
jeryj 964d06d
e2e tests: Top Toolbar in edit mode
jeryj 8050ffb
e2e tests: Top toolbar + select mode
jeryj a65fd0a
Refactor toggle fixed toolbar to playwright editor class
jeryj 02cfb03
Refactor: consolodate e2e locators
jeryj abeb991
Refactor: Combine tests into fewer cases to save execution time
jeryj 26d79a2
Use POM-style ToolbarUtils for e2e test
jeryj a4c4633
Improve naming of isFixed to setIsFixedToolbar
jeryj 29ccd55
Improve naming to shouldUseKeyboardFocusShortcut
jeryj f51fb72
Simplify logic for setting isBlockWithToolbarSelected
jeryj 6bfb00f
Rename toggleFixedToolbar util to setIsFixedToolbar
jeryj 766ef57
Refactor shouldShowContextualToolbar and canFocusHiddenToolbar into u…
jeryj 9657c9d
Export useShouldContextualToolbarShow
jeryj 82784d6
Add hasClientId check, as we can't focus a block toolbar without a bl…
jeryj aede555
Implement useShouldContextualToolbarShow in header toolbar
jeryj 21deaa2
Add tests for smaller viewports
jeryj 47c6561
Update e2e tests to address new unified toolbar view
jeryj 3eef424
Make useShouldContextualToolbarShow private
jeryj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add useKeyboardShortcut prop to NavigableToolbar and useToolbarFocus
The 'core/block-editor/focus-toolbar' shortcut (alt + F10) selects the active navigable toolbar's fi rst tabbable item, but when there are multiple navigable toolbars, it places focus on all of the act ive navigable toolbar components. This results in an odd state of two tooltips being open. This comm it scaffolds the ability to disable the keyboard shortcut from applying.
- Loading branch information
commit 820035dd61a85d74316c85a917267e056c3aea2b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,7 +93,8 @@ function useToolbarFocus( | |
| focusOnMount, | ||
| isAccessibleToolbar, | ||
| defaultIndex, | ||
| onIndexChange | ||
| onIndexChange, | ||
| useKeyboardFocusShortcut | ||
| ) { | ||
| // Make sure we don't use modified versions of this prop. | ||
| const [ initialFocusOnMount ] = useState( focusOnMount ); | ||
|
|
@@ -103,8 +104,14 @@ function useToolbarFocus( | |
| focusFirstTabbableIn( ref.current ); | ||
| }, [] ); | ||
|
|
||
| const focusToolbarViaShortcut = () => { | ||
| if ( useKeyboardFocusShortcut ) { | ||
| focusToolbar(); | ||
| } | ||
| }; | ||
|
|
||
| // Focus on toolbar when pressing alt+F10 when the toolbar is visible. | ||
| useShortcut( 'core/block-editor/focus-toolbar', focusToolbar ); | ||
| useShortcut( 'core/block-editor/focus-toolbar', focusToolbarViaShortcut ); | ||
|
|
||
| useEffect( () => { | ||
| if ( initialFocusOnMount ) { | ||
|
|
@@ -147,6 +154,7 @@ function useToolbarFocus( | |
| function NavigableToolbar( { | ||
| children, | ||
| focusOnMount, | ||
| useKeyboardFocusShortcut = true, | ||
|
||
| __experimentalInitialIndex: initialIndex, | ||
| __experimentalOnIndexChange: onIndexChange, | ||
| ...props | ||
|
|
@@ -159,7 +167,8 @@ function NavigableToolbar( { | |
| focusOnMount, | ||
| isAccessibleToolbar, | ||
| initialIndex, | ||
| onIndexChange | ||
| onIndexChange, | ||
| useKeyboardFocusShortcut | ||
| ); | ||
|
|
||
| if ( isAccessibleToolbar ) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.