-
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
Search: Add contextual defaults when inserted in Navigation block #36125
Conversation
@@ -288,7 +288,9 @@ function navStripHTML( html ) { | |||
function LinkControlTransforms( { block, transforms, replace } ) { | |||
return ( | |||
<div className="link-control-transform"> | |||
<h3 className="link-control-transform__subheading">Transform</h3> | |||
<h3 className="link-control-transform__subheading"> | |||
{ __( 'Transform' ) } |
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.
Unrelated, but needed 😄
Size Change: +154 B (0%) Total Size: 1.08 MB
ℹ️ View Unchanged
|
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.
Thanks, Nik.
This enhancement works as expected and doesn't suffers from the issue of updating existing blocks.
I also like @talldan's suggestion about using variations for contextual defaults, but I think we can explore this when more blocks need this feature.
We can also close the original PR once this gets merged - #35688. |
Thank you Nik, George and Vicente for all tackling this challenge! |
Resolves: #31127
This PR is an alternative of #36026 and adds some defaults to the
Search
block, when inserted inNavigation
block.Testing instructions
Search
block in a Navigation block and observe that gets the desired defaultsSearch
and observe that still gets the desired defaultsSearch
outside ofNavigation
and observe that has the base defaultsNotes
I used
wasBlockJustInserted
selector, but in general I think this selector needs more study to make it work more reliably. I believe this works fine (as per my testing) forNavigation
block, just because we can't have theslash inserter
inside this block.I tried adding the
Group
as another parent to check to apply these defaults but this works only when themain and quick
inserters are used.wasBlockJustInserted
updates its value inINSERT_BLOCKS
action, but theslash inserter
(block autocompleter) dispatches anREPLACE_BLOCKS
action when a block is added.