Skip to content
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

Merged
merged 1 commit into from
Nov 11, 2019

Conversation

getdave
Copy link
Contributor

@getdave getdave commented Nov 8, 2019

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

Screen Capture on 2019-11-08 at 17-31-26

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@getdave getdave added the [Block] Navigation Affects the Navigation Block label Nov 8, 2019
@getdave getdave self-assigned this Nov 8, 2019
@getdave getdave added this to 👀 PRs to review in Navigation editor via automation Nov 8, 2019
@@ -245,7 +245,7 @@ export default compose( [
hasDescendants: !! getClientIdsOfDescendants( [ clientId ] ).length,
};
} ),
withDispatch( ( dispatch, ownProps ) => {
withDispatch( ( dispatch, ownProps, registry ) => {
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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 ).

@getdave
Copy link
Contributor Author

getdave commented Nov 11, 2019

Waiting on build issues to merge...

@getdave getdave merged commit 6f4dfc1 into master Nov 11, 2019
Navigation editor automation moved this from 👀 PRs to review to ✅ Done Nov 11, 2019
@getdave getdave deleted the fix/nav-block-items-prepeneded-by-toolbar-btn branch November 11, 2019 09:54
Copy link
Contributor

@mcsf mcsf left a 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 ) => {
Copy link
Contributor

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 ).

@youknowriad youknowriad added this to the Gutenberg 6.9 milestone Nov 11, 2019
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
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Navigation Menu: Nested menu-items are prepended instead of appended
4 participants