-
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
Replace block settings menu with a custom menu in off canvas editor #46675
Conversation
Size Change: +126 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
packages/block-library/src/navigation/edit/menu-inspector-controls.js
Outdated
Show resolved
Hide resolved
Some of the default actions do still make sense:
I wonder if we should keep these for consistency? |
packages/block-library/src/navigation/edit/menu-inspector-controls.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/off-canvas-editor/block.js
Outdated
Show resolved
Hide resolved
Adding the actions below expands the scope of this PR. I wonder if it wouldn't be wiser to add each one in subsequent PRs as they're not not working because we need to fix various limitations of how these actions were initially implemented (copy, move to, lock) or how the off canvas handles them (duplicate). Copy blockThis makes no sense because there is no paste block option. I am personally against this option in the off canvas editor. DuplicateThis works but should be updated to not select the block in the canvas as it results in the off canvas editor disappearing - it should behave like the list view. Move toThis works but moves the focus to the canvas and replaces the off canvas editor with the inspector tools of the moved block - it should be updated so that if it is actioned from the off canvas editor the item is moved via keyboard in that tree view. This requires:
LockThis appears to work but it does not when applied to a navigation link - the only effect is that the link is not removable, but the link and the label can be edited so pretty pointless. |
The questions for @WordPress/gutenberg-design are:
|
e854e6e
to
8eb3fa0
Compare
My quick take on this is: it's okay for the ellipsis menu for the navigation inspector interface to be different from the one in the general List View. Not all actions are going to be relevant here. Technically it seems like there's value in code-reuse, I'll let you consider that, but designwise, I don't think the contents have to necessarily be the same. Although the tree view is similar, ultimately what we're building here in the inspector, as I see it, is a UI to apply to the navigation block and to contentOnly locked patterns, and so long as the controls can be made appropriate for those two, I think we can be flexible. |
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.
LGTM
What?
The tree view displayed by the navigation block (which is temporarily called the "off canvas editor") is a modified List View. Like the list view by default this tree shows a dot "more" menu with the typical block actions (make template part, duplicate, copy etc.).
This PR implements a way to replace the default block menu in this tree view of blocks with a custom one decided where the list view is instanced.
Why?
In the particular case of the navigation block:
The standard way to register items via plugins for the block settings menu is not flexible enough to allow modifications like the ones above.
How?
Luckily the List view implements a context that is consumed for it's many children, so adding a new more menu is only:
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast