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

Ellipsis menu in block navigator #22427

Merged
merged 13 commits into from
May 21, 2020
Merged

Ellipsis menu in block navigator #22427

merged 13 commits into from
May 21, 2020

Conversation

adamziel
Copy link
Contributor

@adamziel adamziel commented May 18, 2020

Description

This is a first attempt at adding an ellipsis menu to block navigation. The menu only offers a few basic options in this initial PR.

A follow-up PR will bring in more menu items. I propose merging/reviewing these PRs in the following order:

  1. Ellipsis menu in block navigator #22427 - introduce very basic ellipsis menu to the block navigation
  2. Allow explicitly specifying additional block navigation menu options in block edit function #22463 - allow the block to define additional ellipsis menu items
  3. Allow explicitly specifying additional block navigation menu options in block edit function #22463 - introduce an abstraction that takes care of the toolbar items and ellipsis menu items at the same time

Related issue: #22089

How has this been tested?

  1. Enable the experimental navigation screen in Gutenberg experiments
  2. Go to Navigation (beta)
  3. Add a few menu items
  4. Confirm the ellipsis menu is there and that it offers a few basic options.

Screenshots

Zrzut ekranu 2020-05-20 o 12 32 48

Types of changes

New feature (non-breaking change which adds functionality)

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.

@adamziel adamziel added [Block] Navigation Affects the Navigation Block [Feature] List View Menu item in the top toolbar to select blocks from a list of links. labels May 18, 2020
@adamziel adamziel self-assigned this May 18, 2020
@adamziel adamziel requested a review from talldan May 18, 2020 15:25
@github-actions
Copy link

github-actions bot commented May 18, 2020

Size Change: +429 B (0%)

Total Size: 1.11 MB

Filename Size Change
build/annotations/index.js 3.62 kB -1 B
build/block-directory/index.js 6.93 kB -1 B
build/block-editor/index.js 105 kB +278 B (0%)
build/block-editor/style-rtl.css 10.9 kB +54 B (0%)
build/block-editor/style.css 10.9 kB +51 B (0%)
build/block-serialization-default-parser/index.js 1.88 kB -1 B
build/blocks/index.js 48.1 kB -2 B (0%)
build/compose/index.js 6.67 kB -1 B
build/data/index.js 8.43 kB +4 B (0%)
build/date/index.js 5.47 kB +2 B (0%)
build/deprecated/index.js 771 B -1 B
build/edit-navigation/index.js 6.63 kB +24 B (0%)
build/edit-post/index.js 302 kB +18 B (0%)
build/edit-site/index.js 12.8 kB +1 B
build/edit-widgets/index.js 7.73 kB +1 B
build/editor/index.js 44.3 kB +2 B (0%)
build/format-library/index.js 7.64 kB +1 B
build/redux-routine/index.js 2.85 kB -1 B
build/url/index.js 4.02 kB +1 B
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.02 kB 0 B
build/api-fetch/index.js 3.39 kB 0 B
build/autop/index.js 2.83 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/style-rtl.css 790 B 0 B
build/block-directory/style.css 791 B 0 B
build/block-library/editor-rtl.css 7.22 kB 0 B
build/block-library/editor.css 7.22 kB 0 B
build/block-library/index.js 119 kB 0 B
build/block-library/style-rtl.css 7.48 kB 0 B
build/block-library/style.css 7.48 kB 0 B
build/block-library/theme-rtl.css 683 B 0 B
build/block-library/theme.css 685 B 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/components/index.js 182 kB 0 B
build/components/style-rtl.css 17.1 kB 0 B
build/components/style.css 17.1 kB 0 B
build/core-data/index.js 11.4 kB 0 B
build/data-controls/index.js 1.29 kB 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 3.11 kB 0 B
build/edit-navigation/style-rtl.css 857 B 0 B
build/edit-navigation/style.css 856 B 0 B
build/edit-post/style-rtl.css 12.2 kB 0 B
build/edit-post/style.css 12.2 kB 0 B
build/edit-site/style-rtl.css 5.22 kB 0 B
build/edit-site/style.css 5.22 kB 0 B
build/edit-widgets/style-rtl.css 4.59 kB 0 B
build/edit-widgets/style.css 4.59 kB 0 B
build/editor/editor-styles-rtl.css 425 B 0 B
build/editor/editor-styles.css 428 B 0 B
build/editor/style-rtl.css 5.07 kB 0 B
build/editor/style.css 5.08 kB 0 B
build/element/index.js 4.65 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 B 0 B
build/hooks/index.js 2.13 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.56 kB 0 B
build/is-shallow-equal/index.js 711 B 0 B
build/keyboard-shortcuts/index.js 2.51 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.13 kB 0 B
build/list-reusable-blocks/style-rtl.css 226 B 0 B
build/list-reusable-blocks/style.css 226 B 0 B
build/media-utils/index.js 5.29 kB 0 B
build/notices/index.js 1.79 kB 0 B
build/nux/index.js 3.4 kB 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/plugins/index.js 2.56 kB 0 B
build/primitives/index.js 1.5 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/rich-text/index.js 14.8 kB 0 B
build/server-side-render/index.js 2.68 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.28 kB 0 B
build/viewport/index.js 1.84 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@adamziel adamziel marked this pull request as ready for review May 19, 2020 11:10
@adamziel
Copy link
Contributor Author

adamziel commented May 19, 2020

Right now this uses BlockSettingsMenu as it is - one possible improvement would be only taking the dropdown menu part of BlockSettingsMenu, and not rendering the ToolbarGroup or ToolbarItem. It's not an overly big deal though.

@noisysocks noisysocks added [Feature] Navigation Screen [Type] Enhancement A suggestion for improvement. and removed [Block] Navigation Affects the Navigation Block labels May 20, 2020
Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

  1. The More options button overflows past the Navigation structure panel on my 1440px wide viewport.

    Screen Shot 2020-05-20 at 15 31 46
  2. The app crashes when I click on an item's text and then click on the More options button.

    crash

  3. Should we add the ellipsis to the Block Navigator in the post editor?

    localhost_8888_wp-admin_post php_post=141 action=edit

[
__experimentalWithBlockNavigationSlots,
__experimentalWithEllipsisMenu,
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using context for these two settings? Would prop-passing be simpler? 🙂

Copy link
Contributor Author

@adamziel adamziel May 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I'd say it would be, but this is a quite entangled network of components with a recursive structure - we'd have to pass these two props through ~5 layers of components. I think the context makes it simpler in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think context saving some repeated props works.

@jasmussen
Copy link
Contributor

If you use the vertical ellipsis, it doesn't take up as much space. The smallest tap target we accept is 24x24, so there's a great deal of horizontal space to find there.

With regards to the mover control, I'm unsure if that's part of this PR or not, if it isn't we can find a way to address this separately.

The movers need to sync up with what we're going to explore next for block movers (this: #21935 (comment)) — so a 48px tall unit that uses the same icons.

@adamziel
Copy link
Contributor Author

adamziel commented May 20, 2020

@noisysocks @jasmussen all good notes - thank you so much! I addressed your feedback and this PR is ready for a re-review now :-)

@adamziel
Copy link
Contributor Author

With regards to the mover control, I'm unsure if that's part of this PR or not, if it isn't we can find a way to address this separately.

@jasmussen it's not a part of this PR - these movers are already there.

adamziel and others added 2 commits May 20, 2020 14:27
Copy link
Contributor

@draganescu draganescu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and read the code, it works all right, and the code integrates all the other reviewers' feedback.

@adamziel adamziel merged commit 60fbabc into master May 21, 2020
@adamziel adamziel deleted the add/ellipsis-menu branch May 21, 2020 08:47
@github-actions github-actions bot added this to the Gutenberg 8.2 milestone May 21, 2020
Comment on lines +51 to +52
__experimentalWithEllipsisMenu: withEllipsisMenu,
__experimentalWithEllipsisMenuMinLevel: ellipsisMenuMinLevel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing, but I think we shouldn't use the term EllipsisMenu for the menu.

Elsewhere in the code it's called BlockSettings, so I think it'd be good to stay consistent with that.

Copy link
Contributor Author

@adamziel adamziel May 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been pondering this exact issue. The two are not exactly the same. BlockSettings offers certain set of options:

Zrzut ekranu 2020-05-21 o 11 40 08

And the ellipsis menu is supposed to include everything from BlockSettings PLUS everything from the toolbar as well:

Zrzut ekranu 2020-05-21 o 11 40 47

While I don't love the name EllipsisMenu, I am also not convinced that using the name BlockSettings for both menus is the right thing to do here. Let's discuss that more on #22462 - we may need to rethink the naming strategy a little bit more as we also have BlockControls and then UniversalBlockControl. It's just too many similar names in circulation :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In either case EllipsisMenu is bad because it references the icon we use for the menu. What if we change that icon to a circle?

If we want a menu that includes the BlockControls and the BlockSettings which is used by a Block Navigator Item, we'd wrap the two (for reuse if that is the case) in a thing that references the functionality, for example BlockNavigatorItemSettings.

Also, since BlockSettings has Slots we can use these to extend that in the BlockNavigatorItemSettings. If we want slots to be available for actions/ items specific to to BlockNavigatorItem then we'd add slots to BlockNavigatorItemSettings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@draganescu as I mentioned I agree we shouldn't call it EllipsisMenu - I was simply looking for a better option :-) BlockNavigatorItemSettings sounds pretty good so I went with it in #22463

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I don't think BlockNavigatorItemSettings is right either. The Navigator is called Navigation internally and the Item is called Block, so I reckon BlockNavigationBlockSettings is perhaps the right way to go.

I know it's weirdly repetitive, but it's just a component name, and it makes it pretty clear where it lives and that it's a version of the BlockSettings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamziel @draganescu @talldan I'm confused here, why shouldn't the two menus be the same?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in the Navigator the Items might have additional options that don't make sense in the block's menu. I don't know if that is the case @mtias. One example is add submenu, but that should sit fine with the block as well, why not?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they seem to serve conceptually the exact same purpose. If there are certain features that would not make sense on one or the other, we should probably handle it through configuration / context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] List View Menu item in the top toolbar to select blocks from a list of links. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants