-
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
Fixes to append items via toolbar #18412
Conversation
@@ -245,7 +245,7 @@ export default compose( [ | |||
hasDescendants: !! getClientIdsOfDescendants( [ clientId ] ).length, | |||
}; | |||
} ), | |||
withDispatch( ( dispatch, ownProps ) => { | |||
withDispatch( ( dispatch, ownProps, registry ) => { |
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 think the only suggestion I'd have would be to maybe consider destructuring registry
to just pick select
?
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 had some advice from @mcsf that Gutenberg prefers being explicit about where you are accessing the properties of data controls. I took this as avoiding unnecessary destructuring in/around select
/dispatch
/registry
. I could be wrong.
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 had some advice from @mcsf that Gutenberg prefers being explicit about where you are accessing the properties of data controls. I took this as avoiding unnecessary destructuring in/around
select
/dispatch
/registry
. I could be wrong.
Thanks for thinking about my advice 😄. In this case I don't really have an opinion, since, in the context of withDispatch
, select
could only come from one place.
My main point — which was merely stylistic — in the other PR was about not extracting the selectors into their own variable, e.g. const { getFoos } = select( store )
, and instead always calling select( store ).getFoos( ...args )
.
Waiting on build issues to merge... |
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.
Have you tried calling insertBlock
with an undefined index
? I had noticed that the argument was considered optional so I tried dropping it, and I think the same effect is achieved.
You can see in the order
reducer where index
defaults to the substate's length:
const { index = subState.length } = action; |
Quick check with @youknowriad: the documentation for insertBlock(s)
isn't super explicit about appending when index
is missing, but the signature does state "inserted, optionally at a specific index respective a root block list". We can recommend this usage, right?
@@ -245,7 +245,7 @@ export default compose( [ | |||
hasDescendants: !! getClientIdsOfDescendants( [ clientId ] ).length, | |||
}; | |||
} ), | |||
withDispatch( ( dispatch, ownProps ) => { | |||
withDispatch( ( dispatch, ownProps, registry ) => { |
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 had some advice from @mcsf that Gutenberg prefers being explicit about where you are accessing the properties of data controls. I took this as avoiding unnecessary destructuring in/around
select
/dispatch
/registry
. I could be wrong.
Thanks for thinking about my advice 😄. In this case I don't really have an opinion, since, in the context of withDispatch
, select
could only come from one place.
My main point — which was merely stylistic — in the other PR was about not extracting the selectors into their own variable, e.g. const { getFoos } = select( store )
, and instead always calling select( store ).getFoos( ...args )
.
Closes #18299
Updates the Nav Block toolbar "insert" button to append items at the end of the currently selected Nav Block Item.
Previously this was hardcoded to
0
which meant they were always prepended.How has this been tested?
Manual testing.
Screenshots
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: