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

Block Editor: Introduce stable BlockSettingsMenuControls slot #20233

Merged
merged 3 commits into from
Feb 18, 2020

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Feb 14, 2020

Description

Part of #20116.

It refactors __experimentalBlockSettingsMenuPluginsExtension and promotes it to stable API under BlockSettingsMenuControls name. I was able to simplify the implementation a bit by moving all logic related to block-editor to the BlockSettingsMenuControls component that.

How has this been tested?

Add a few different blocks and make sure that the block settings menu works as before.

Screenshots

Screen Shot 2020-02-14 at 11 31 09

Types of changes

Refactoring.

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.

@gziolo gziolo added [Feature] Extensibility The ability to extend blocks or the editing experience [Package] Block editor /packages/block-editor labels Feb 14, 2020
@gziolo gziolo self-assigned this Feb 14, 2020
@gziolo gziolo mentioned this pull request Feb 14, 2020
18 tasks
@gziolo gziolo added the [Status] In Progress Tracking issues with work in progress label Feb 14, 2020
@gziolo
Copy link
Member Author

gziolo commented Feb 14, 2020

@youknowriad, with all the planned changes to the block toolbar, is there still need for __experimentalBlockSettingsMenuFirstItem or can we inline it in the toolbar and call it the day? 😄

An alternative approach would be to rename it to BlockSettingsMenuInspectorControls and made it very inflexible. As far as I can tell, you would only need to pass down onToggle, isOpened and shortcutName. It makes me also wonder whether we could use withFilters instead and provide and empty component by default.

@youknowriad
Copy link
Contributor

@gziolo Yes, it's still needed for now, I think we should just mark it as unstable instead of experimental and leave it.

@oandregal
Copy link
Member

oandregal commented Feb 14, 2020

I'm thinking we may want to use a different name as to better communicate the component's intention. How about BlockSettingsMenuPlugins?

@gziolo
Copy link
Member Author

gziolo commented Feb 17, 2020

I'm thinking we may want to use a different name as to better communicate the component's intention. How about BlockSettingsMenuPlugins?

I didn't go with Plugins postfix only because of all other slots in @wordpress/block-editor avoid using this keyword:

How about BlockSettingsMenuControls or BlockSettingsMenuItems?

@gziolo gziolo requested review from mtias and mcsf February 17, 2020 14:56
@gziolo gziolo changed the title Block Editor: Introduce stable BlockSettingsMenuGroup slot Block Editor: Introduce stable BlockSettingsMenuControls slot Feb 17, 2020
@gziolo
Copy link
Member Author

gziolo commented Feb 17, 2020

In I 2a10f6c try BlockSettingsMenuControls. I also added documentation.

I also have another proposal for the name BlockSettingsMenuActions.

@gziolo gziolo removed the [Status] In Progress Tracking issues with work in progress label Feb 17, 2020
@gziolo gziolo marked this pull request as ready for review February 17, 2020 15:37
</MenuGroup>
<BlockSettingsMenuControls.Slot
Copy link
Member

Choose a reason for hiding this comment

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

By making the slot a new MenuGroup we are introducing a visual difference (notice the separator before the reusable blocks item in the menu).

Before After
2002-blocksettingsmenu-before 2002-blocksettingsmenu-after

I think this is fine, especially because that area is variable (third-parties can hook into and add new contents). Raised in case this needed a design 👍

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, it doesn't change the keyboard interaction.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this seems fine.

Copy link
Member

Choose a reason for hiding this comment

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

For completeness, this is how it looks with plugins:

2002-blocksettingsmenu-after-with-plugin

Plugins are added before the core utils (reusable blocks, groups), as it works today.

Copy link
Member Author

Choose a reason for hiding this comment

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

Plugins are added before the core utils (reusable blocks, groups), as it works today.

This is a bit unfortunate. I think before we had a slot in another slot to make it work. Should we bring it back even though you (and me) liked the simplification? :)

Copy link
Member

Choose a reason for hiding this comment

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

I meant that it works the same as it did! In master, the plugins are also loaded before reusable and group items. If anything, this PR visually clarifies where plugins are added due to the new separator.

Copy link
Member

@oandregal oandregal left a comment

Choose a reason for hiding this comment

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

This breaks third-party extensibility.

This is how I've tested:

  • Activate a plugin that adds a new item to the block settings (ex: blocksettingsmenu-plugin).
  • Load the editor.
  • I've got a WSOD kind of error (for some reason, my env is using React production builds so message isn't very useful).

@oandregal
Copy link
Member

I've found why this isn't working for plugins and submitted a change. This is good to land after all those changes are applied.

@gziolo
Copy link
Member Author

gziolo commented Feb 18, 2020

I've found why this isn't working for plugins and submitted a change. This is good to land after all those changes are applied.

Great catch @nosolosw, thanks for proposing the fix 💯

Copy link
Member

@oandregal oandregal left a comment

Choose a reason for hiding this comment

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

Retested this and works as expected. 🚢

gziolo and others added 2 commits February 18, 2020 20:59
It refactors __experimentalBlockSettingsMenuPluginsExtension and promotes it to stable API.
@gziolo gziolo force-pushed the update/block-settings-menu-group branch from ecbc85c to 749c3ff Compare February 18, 2020 20:00
@gziolo
Copy link
Member Author

gziolo commented Feb 18, 2020

Thanks @nosolosw for all your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Package] Block editor /packages/block-editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants