-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Adds the block hierarchy navigation menu to the header #10545
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
fceb875
Adds the block hierarchy navivation menu to the header
youknowriad 8eee332
Avoid auto-selecting inner blocks when selecting the parent block
youknowriad 94a20dd
Show block hierarchy for container blocks
youknowriad a110a3b
highlight the selected block
youknowriad be61554
Add a unit test for the newly added selector
youknowriad b1bbd5e
Adding an e2e test
youknowriad 4fcaff2
Replace block names by block titles
youknowriad e1b402c
Fix unit tests
youknowriad 3d4c28f
Fix e2e tests
youknowriad 5779576
Update the selector docs
youknowriad 7ea0064
Tweak the design of the block navigation menu
youknowriad ba32da1
Compress the block hierarchy tree
youknowriad 083d2df
Update inner column block icon.
mtias b22412a
Avoid showing the parent block's borders if a child block is selected
youknowriad 5fc0693
Simplify the menu's label
youknowriad b67a487
Tweak the selected block's style
youknowriad d55686c
Darker text color for the selected block
youknowriad e8af488
Memoize the block parent's selectors
youknowriad a014263
Adding root level block navigation
youknowriad e1fea28
Adding a keyboard shortcut to open the navigation menu
youknowriad ca407ed
Avoid wrapping function descriptions
youknowriad c81b4a7
Use Path for a mobile-friendly SVG
youknowriad affb3b3
Extract inner blocks check to a dom utility
youknowriad 67e8451
Fix unit tests
youknowriad b6099fa
Fix e2e tests
youknowriad 0ad245e
Add aria-label to block navigation list to improve context with keybo…
tofumatt 9909857
Use the label prop to label the MenuGroup
youknowriad e70e5fb
Use access + b shortcut to avoid ambiguity
youknowriad 82394d3
Add role="presentation" to the items that should be invisible a11y wise
youknowriad 2b796a7
Fix unit tests
youknowriad a1c039d
change shortcuts, improve tests, and show empty navigator when no blo…
tofumatt 45b7686
Tweak tests; use o instead of l
tofumatt 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
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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
46 changes: 46 additions & 0 deletions
46
packages/editor/src/components/block-navigation/dropdown.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Fragment } from '@wordpress/element'; | ||
import { IconButton, Dropdown, SVG, Path, KeyboardShortcuts } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { rawShortcut } from '@wordpress/keycodes'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockNavigation from './'; | ||
|
||
const menuIcon = ( | ||
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20"> | ||
<Path d="M5 5H3v2h2V5zm3 8h11v-2H8v2zm9-8H6v2h11V5zM7 11H5v2h2v-2zm0 8h2v-2H7v2zm3-2v2h11v-2H10z" /> | ||
</SVG> | ||
); | ||
|
||
function BlockNavigationDropdown() { | ||
return ( | ||
<Dropdown | ||
renderToggle={ ( { isOpen, onToggle } ) => ( | ||
<Fragment> | ||
<KeyboardShortcuts | ||
bindGlobal | ||
shortcuts={ { | ||
[ rawShortcut.access( 'o' ) ]: onToggle, | ||
} } | ||
/> | ||
<IconButton | ||
icon={ menuIcon } | ||
aria-expanded={ isOpen } | ||
onClick={ onToggle } | ||
label={ __( 'Block Navigation' ) } | ||
/> | ||
</Fragment> | ||
) } | ||
renderContent={ ( { onClose } ) => ( | ||
<BlockNavigation onSelect={ onClose } /> | ||
) } | ||
/> | ||
); | ||
} | ||
|
||
export default BlockNavigationDropdown; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is it we're trying to do here? And why is it inconsistent with the behavior in
componentDidMount
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so if it's to avoid "select" actually causing one of its inner blocks to become selected, can't this also happen in a newly-mounted block as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should reconsider whether to call
focusTabbable
on a selection update as well. I don't recall what we need it for.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial implementation here was to avoid selecting innerBlocks in all cases but this breaks the writing flow when inserting columns (it actually broke 2 e2e tests) because the first paragraph was not focused in that case. I did consider whether it's fine to not focus the first paragraph in that case as assume we hit "tab" or click no the appender of the column block first but I think from a "Writing flow" perspective, it's better if we focus the first paragraph in a column directly when creating a columns block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As "Columns" evolve, it'd be natural to focus on the container when it is added rather than on the paragraph within.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I've found this behavior to be a weird / unexpected side effect of focus behaviors. On the Layout<->Writing spectrum, Columns falls more on the former, so I don't necessarily see the paragraph creation / focus being a necessity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes one idea I had was to rewrite the columns block similarly to the table block where you select the number of columns before typing but I though this was out of the scope of this PR anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting a sense we're becoming very ad hoc with how and when we expect focus transitions to occur upon block selection, hacking in various conditions to preserve intended flows while losing sight of what those intended flows are. It's signalling to me that naively checking for / comparing on
isSelected
fromBlockListBlock
is not serving us very well, and that perhaps it ought to be moved / refactored to more appropriately capture the user interactions where we expect it to occur: as best I can tell, this is mostly in splitting / merging / replacing actions occurring while typing within aRichText
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For columns I think the right way is to not focus the inner block. In general, I don't see a reason for focusing the inner block since when you add a container (columns, section, etc) you are likely to want to customize the container first. Pushing you to a paragraph seems detrimental unless it's a block like "Quote".