-
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
Fix insertion point displaying when there are no inserter items #32576
Fix insertion point displaying when there are no inserter items #32576
Conversation
Size Change: +13 B (0%) Total Size: 1.03 MB
ℹ️ View Unchanged
|
Looks like I'll need to revisit this once #31896 is merged, as that removes the isHidden variable this uses. |
Could we check the setting directly, instead of inserter items? This component is also being used for drag and drop and could in the future be used for more things like the "Move to" feature. |
b4022c0
to
91d2a73
Compare
@ellatrix I've reworked this and added a template lock check to the selector. |
return false; | ||
} | ||
|
||
return true; |
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.
I never know what's the best layer to adjust here. Should we (also or instead) prevent insertion points to be set if the template is locked? And if so, in the component or reducer? I know that in a lot of other places we're doing a lot to prevent actions from even dispatching to the store if we know it won't change anything.
The question is a bit more general, but I think it would be good to see more consistency across the code base.
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.
For example, for the block drop zone, we are completely disabling it when the template is locked:
isDisabled: isLockedAll, |
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.
So maybe we should disable the in-between inserter if the template is locked?
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.
In my testing this fixes all previous issues I noticed in the Widgets editor.
Description
Fixes #28123
In locked template areas (and other between blocks places where blocks can't be inserted), the insertion point indicator was still being displayed, though just the blue line without an inserter button.
To solve this, the
isInsertionPointVisible
selector now checks whether the insertion point's root client id has a template lock.To solve this, theInsertionPointPopover
component needs to do its own check forhasInserterItems
to get around this issue. This matches what the inserter button does:gutenberg/packages/block-editor/src/components/inserter/index.js
Line 225 in 3c722bf
gutenberg/packages/block-editor/src/components/inserter/index.js
Lines 296 to 299 in 3c722bf
How has this been tested?
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).