-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Nav offcanvas disable direct insertion #46898
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
Conversation
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
|
Size Change: +12 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
draganescu
approved these changes
Jan 5, 2023
Contributor
draganescu
left a comment
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.
Code LGTM and the functionality is aces!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Block] Navigation
Affects the Navigation Block
[Package] Block editor
/packages/block-editor
[Type] Experimental
Experimental feature or API.
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.
What?
Allows consumers of the
<Inserter>component to manually disable the direct block insertion functionality.Disables for the Nav Offcanvas experiment.
Why?
Contributors have disucssed that in the offcanvas the insertion of a Nav link should be 2 step:
Most commonly this manifests as
This PR enables that functionality whilst also preserving the direct insertion for the editor canvas (as per
trunk).How?
The process by which direct block insertion is achieved has been previously detailed.
The configuration happens in the Nav block
inner-blocks.jscomponent.gutenberg/packages/block-library/src/navigation/edit/inner-blocks.js
Lines 116 to 117 in 8e93b93
Therefore there is no way to make this configuration conditional in relation to usage within the offcanvas.
As a result this PR adds a new prop which provides a means to hard overide the direct insertion config which is provided by a
withSelectHOC.This prop defaults to
trueto ensure that the existing functionality is preserved by default. This makes this PR backwards compatible.However when the new prop is set to true...
....then it short circuits all the direct insert lookup and simply provides the standard block picker UI.
Testing Instructions
Backwards Compat.
packages/block-editor/src/components/off-canvas-editor/appender.jstry removing theshouldDirectInsertprop.Testing Instructions for Keyboard
Screenshots or screencast
Screen.Capture.on.2023-01-05.at.09-57-57.mp4