-
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
Update: Auto insert page-link on navigation sidebar. #48745
Update: Auto insert page-link on navigation sidebar. #48745
Conversation
Size Change: +35 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
Flaky tests detected in 20c1b48. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4326246689
|
Nice, this makes it much easier to add Page Links to the menu which is a very common use case. Before before.mp4After after.mp4 |
@jorgefilipecosta, @jameskoster is this alternative to #48724? |
function PageLinkInserter( { rootClientId } ) { | ||
const { insertBlock } = useDispatch( blockEditorStore ); | ||
const { getBlockOrder } = useSelect( blockEditorStore ); | ||
const insertPageLink = useCallback( () => { |
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.
Nit: Probably no need for useCallback
here. The SidebarButton
component isn't memoized and will re-render whenever its parent re-renders. So we don't need to pass a referentially stable callback to it.
No, this is in addition to. 48724 is important because when building any navigation menu, you're likely to be using Page Links. The way it behaves is that if you only ever have menu items in your menu, you get this "light weight" navigation building flow where navigation items are inserted directly, skipping the quick inserter. This is similar to how the Buttons block defaults to inserting buttons, skipping the need to pick "button" from the inserter. As soon as you have other block types inside the navigation wrapper, such as a site logo or a search field, you get the regular quick inserter, which per 48724 should still pin "page links" for quick access. |
Speaking of: this PR is working well for me in that it defaults to the Page Links: It doesn't have the same behavior as the navigation block, though, as described here, where as soon as you have a block inside the nav wrapper that isn't a menu item, it falls back to the regular inserter. It should probably be the same behavior here. Can we use the exact same componentry as the off-canvas navigation editor has? Ideally the code would be reused. |
I don't see the logic for this behavior in the code. Currently, PR replaces block inserter with a custom inserter that only handles Page Links. |
We currently don't have this logic, but it is a simple change to include. I'm unsure if this PR is needed, given that #48740 was already merged. |
I've removed backport label until we have a final decision for this enhancement. |
I don't really understand why we do this 🤔 Adding a Page Link is inherently the most common behavior, regardless of whether the menu contains other block types, no? |
With this PR, we can only add the |
I think the idea, yes, the idea was only to insert page links. If people want other blocks, the page link creation popover allows changing to other blocks. |
Closing this PR, as right now the inserter is disable and what the inserter will look like is not yet decided. |
This PR auto inserts page links on the navigation sidebar.
cc: @jasmussen, @jameskoster