-
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
Block Hooks: Do not remove toggle if hooked block is present elsewhere #57928
Block Hooks: Do not remove toggle if hooked block is present elsewhere #57928
Conversation
Size Change: -17 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Flaky tests detected in a0d954caa701972f2837fd612ff0488a00a9b720. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7558819934
|
a0d954c
to
a322048
Compare
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and worked as expected.
00fab78
to
028cc9f
Compare
Thank you, Carlos! Rebased to (hopefully) make PHPUnit tests pass before merging 🤞 |
@ockham where was this feedback shared initially? It sounds like the multiple blocks is a specific case to address, but I'd find it weird if a block added anywhere in the tree would interact with a toggle on block specific context. |
I was initially shared as part of this comment (and here's my reply).
On second glance, I realize that the PR title might be a bit misleading, so just to make sure we're on the same page: It's the previous behavior that did that, i.e. remove the toggle from an anchor block if an instance of the hooked block was present elsewhere. What the PR did was to remove that special case, such that the presence of another instance of the hooked block no longer has any impact on the toggle. It now behaves the same way regardless of whether there's 0 other instances of the hooked block, or n > 0. (Maybe a better title would've been something like "Stop removing toggle based on presence of hooked block elsewhere in the tree.") LMK if that's okay, or if you'd rather change the behavior after all! 😊 |
Fixes https://core.trac.wordpress.org/ticket/59955.
What?
Don't remove hooked block toggle from "Plugins" panel if the hooked block is not in its expected location but elsewhere in the block tree.
Why?
Previously, if a hooked block wasn't present in its expected location, but was found somewhere else, we would remove its toggle from the "Plugins" panel, as we'd assume that it was moved by the user to that other location (and that the user was thus familiar with the hooked block and did not need the extra visibility provided by the toggle).
However, this lead to confusion when there were multiple instances of the same anchor block: Once the user removed one of the hooked blocks, the toggle would vanish, as there were still all the other automatically inserted hooked blocks present.
This PR changes the behavior so that the toggle will always be visible.
How?
By changing some logic.
Testing Instructions
To reproduce the issue (on
trunk
):(Undo the change, and/or make sure not to save the template.)
To verify the fix
On this branch, go through the above instructions again. Verify that the buggy behavior (marked ❌ ) has been fixed.
Screenshots or screencast