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

Pattern Overrides: Refactor block toolbar indicator #65058

Open
3 tasks
talldan opened this issue Sep 4, 2024 · 1 comment
Open
3 tasks

Pattern Overrides: Refactor block toolbar indicator #65058

talldan opened this issue Sep 4, 2024 · 1 comment
Labels
[Block] Pattern Affects the Patterns Block [Type] Code Quality Issues or PRs that relate to code quality

Comments

@talldan
Copy link
Contributor

talldan commented Sep 4, 2024

See #65054
Related #62514

Inner blocks of patterns currently use a custom filter to add a block icon to the toolbar. See this code:

return hasPatternOverrides && hasParentPattern ? (
<BlockControls group="parent">
<PatternOverridesToolbarIndicator clientIds={ clientIds } />
</BlockControls>

It was implemented this way in #62514 to try to extract the pattern specific code from the block editor package. It also worked since the pattern block leveraged contentOnly mode where selected blocks didn't have a block icon. That is until #64694 added a block icon for contentOnly blocks.

It's pretty clear now that the abstraction for pattern overrides needs to be changed, so that rather than adding a custom icon, the normal block icon is used instead. Here's the tasks:

  • Remove the filter approach and instead use the regular block icon in the toolbar, revert De-duplicate block toolbar icons for patterns #65054 in the process
  • Find a way to make the overridden block icons have the purple color, maybe a declarative way to mark the overridden blocks as 'synced'.
  • Find a way to display this message in the block switcher dropdown, or reconsider whether it's needed:
Screenshot 2024-09-04 at 3 09 39 PM
@talldan talldan added [Type] Code Quality Issues or PRs that relate to code quality [Block] Pattern Affects the Patterns Block labels Sep 4, 2024
@jeryj
Copy link
Contributor

jeryj commented Sep 4, 2024

One direction to start with this is to separate out the block switcher from the simple icon. It has bothered me that the toolbar icon is powered by the block switcher and has the classname "block-editor-block-switcher__no-switcher-icon" when it is an icon indicator that does nothing.

I'd go in a direction that treats the indicator icon as the first case and then passes it to the switcher if we need to load a switcher rather than having them all combined in one component. I wouldn't mind having the block indicator be exported as well so it can be used elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Pattern Affects the Patterns Block [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

No branches or pull requests

2 participants