-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Zoom Out: Only show the inserters when a block is selected or hovered #63668
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +286 B (+0.02%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js
Outdated
Show resolved
Hide resolved
const isHovered = | ||
hoveredBlockClientId === previousClientId || | ||
hoveredBlockClientId === nextClientId; |
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.
👏🏻 👏🏻 👏🏻 Nice find!
const { | ||
sectionRootClientId, | ||
setInserterIsOpened, | ||
hasSelection, | ||
selectedBlockClientId, | ||
hoveredBlockClientId, | ||
} = useSelect( ( select ) => { | ||
const { | ||
getSettings, | ||
getSelectionStart, | ||
getSelectedBlockClientId, | ||
getHoveredBlockClientId, | ||
} = select( blockEditorStore ); | ||
const { sectionRootClientId: root } = unlock( getSettings() ); | ||
|
||
return { | ||
hasSelection: !! getSelectionStart().clientId, | ||
sectionRootClientId: root, | ||
setInserterIsOpened: | ||
getSettings().__experimentalSetIsInserterOpened, | ||
selectedBlockClientId: getSelectedBlockClientId(), | ||
hoveredBlockClientId: getHoveredBlockClientId(), | ||
}; | ||
}, [] ); |
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.
Seems like some of this could be passed into the component from ZoomOutModeInserters
rather than doing the work again here.
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 can get a persistent inserter button when I:
- Hover into a section
- Hover the inserter button
- Hover into the section after the button
- Hover off the canvas
- Inserter button doesn't disappear
Screen.Recording.2024-07-18.at.9.47.09.AM.mov
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.
This is so much better than the trunk experience that I think we should merge and iterate. There are still things to iron out, but I think this is the right direction.
We want to show the inserters on hover, even if there is no selection.
…-inserter-button.js
…-inserter-button.js
…-inserter-button.js
…-inserter-button.js
59adab5
to
ff91cb0
Compare
I think it's worth keeping an eye on this behavior. While debugging #68875, it was odd that hovering was updating store subscribers until I saw this change. Now, just moving the cursor on the canvas can re-render multiple blocks. Maybe we should defer dispatching the store updates with a pattern similar to a "hover intent". IMO, new selectors/actions should have been private. We missed some of those for the Zoom Out feature and shipped them as public. I'm not sure if it's too late to revert. cc @WordPress/gutenberg-core |
I recall that prior to this PR, I did work on this #44325 to avoid calling actions synchronously when moving the mouse. So it seems that you're suggesting that this PR kind of reverts that right? If it's the case, I'm with you, this is problematic. |
What?
At the moment in Zoom Out mode the inserters always show. This updates the zoom out inserters so that they only show if either, the block is selected, or the block is hovered.
Why?
It's not helpful to show too many inserters, its better to only show the ones we need.
How?
Testing Instructions
Screenshots or screencast