-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conditional Duotone Toolbar Visibilty #31519
Conversation
You should become a contributor to the repo so you don't have to work in a fork anymore ;) This is what I see: Looks good, it seems to fix the issue, and also seems to fix a flicker I noted in #31373. What's the next step on this one? Does it just need a quick code review? |
I started to on some of the newer PRs. My workflow was already set up for using my fork, so I just kept doing that. But I suppose it's a bit easier to check out and test a branch from here rather than my fork. :)
I have it in draft because I'm still exploring other approaches. I'm not particularly fond of the Next, I think I'm going to try using the block attributes instead. I was avoiding it because attributes doesn't seem to be the place to store info that isn't used in the final render (like editing UI), but I found that the margin/padding block support already uses this method. They have an issue with accidentally persisting the values (#31839), but in this case the value does need to be persisted. Another thought I had was to create a system that blocks can use to supply a function to be run to indicate if the block support should be active ( |
Do what works best for you :) — just stating you deserve it at this point. |
732f0aa
to
18b6fd6
Compare
@jasmussen The cover block disables the buttons instead of hiding them like on the image block. Disabled seems the way to go in my opinion, but do you think it would be too confusing to have only a disabled duotone toolbar button when everything else is hidden? |
Good question. Thinking high level, not just about Duotone:
However there's a bit of mixed usage in the editor at the moment, and some gray areas to consider. For example, "Replace" does not make sense to show and gray out on an image placeholder block, because the entire purpose of the setup state is to place. In the case of the Cover block, I think it's actually the odd one out: Most of those toolbar buttons aren't very useful, especially compared to those in the setup state itself. I lean towards this being a better Cover solution: In other words, I think you've stumbled upon a topic that is worth discussing and addressing in a systematic way separately. But for now, I think it would make the most sense to just hide the duotone button on the setup state entirely, and show it first when an image has been added. What do you think? |
fb667b0
to
454ef94
Compare
bbd76b4
to
c5df820
Compare
I think I've landed on the approach that I'm going to be happiest with. Hiding the duotone button is done via block attributes and uses the same location that padding UI controls are set. Blocks that wish to start with duotone hidden can update the default attribute for Since the cover block and image block have many places which set the media url, having the The control is |
Admin e2e failures are broken snapshots now that |
It seems that using EDIT: I opened up a new PR with the alternative approach that sidesteps the issue in #33466. |
Description
A block supporting duotone needs to be able to control the visibility of the toolbar. Data needs to be passed from the supporting block (i.e. image block) to the block supports (i.e. duotone).
See #31373
This change allows the image block to prevent rendering of the duotone toolbar. This has the side-effect of solving the second issue since the point where the duotone toolbar is rendered comes after the rest of the block toolbar items, so the toolbar button is now always rendered at the end.
How has this been tested?
Screenshots
Types of changes
New feature / Bug fix
Checklist:
*.native.js
files for terms that need renaming or removal).