Block Comments: Highlight block with new toggleBlockSpotlight private API#72126
Block Comments: Highlight block with new toggleBlockSpotlight private API#72126
Conversation
|
Size Change: +197 B (+0.01%) Total Size: 1.96 MB
ℹ️ View Unchanged
|
|
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. |
|
I know these are private actions/selectors, but terminology is still specific to Block Comments. A more general solution, even if it's private for now, seems more suitable. What I had in mind:
|
|
@Mamaduka Thanks for the review! Personally, I avoided toggleBlockSpotlight and hasBlockSpotlight because they seemed like they could be confused with spotlight mode. I don't have a strong opinion on the terminology, but what do you think? |
|
Flaky tests detected in f84928b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18337000273
|
|
Looks great at a glance. I'm now subscribed to this PR and hope to find time for a more thorough review (e.g. how does it look with the pinned sidebar closed), but it looks on a decidedly good track. Kudos. |
This action/selector "puts a spotlight" on a block, which is why I suggested those general names. There might be other features that could benefit from using this method in the future. It's not a blocker; we can rename them if needed. |
|
We'll have to modify the selectors' return value, but was there any downside to updating the gutenberg/packages/block-editor/src/components/block-list/index.js Lines 53 to 57 in 9db55b6 |
@Mamaduka Sorry, maybe I don't understand the question, but do you mean we will also be incorporating this new API into Spotlight mode?
@jasmussen It will look like this: 995a639874549a70f23a970c208d3225.mp4 |
|
@t-hamano, I was suggesting reusing the existing condition in the linked file and the CSS styles that are already there. Just a random thought, it's not a blocker. |
|
@jarekmorawski Thanks for the feedback! As for the proposed design change, it might be better to open a new issue. This PR is just to highlight the block, so we won't make any changes to the comment itself. Some useful links: |
|
A meta thought: @adamsilverstein has been exploring collapsed versions of the comment threads when there isn't room to show them perfectly aligned with the block itself. Not a blocker for this PR, probably not for release either, but it will very probably benefit the particular pattern used in the example here. |
Nice instincts. Important to balance that also with the gray color in the inactive comments, as well as the contexts for legibility. It may be fine. |
I see, let's try this in a separate PR. |
|
Just noting that this PR had an impact on "block selection" metric. Any idea what caused this? |
|
Thanks for pointing that out, @youknowriad! Yes, that seems like a big jump - https://www.codevitals.run/project/gutenberg/focus. |
|
Is it because gutenberg/packages/block-editor/src/store/reducer.js Lines 1886 to 1909 in b2cfd06 Can we somehow measure this metric locally or before the merge? |
|
@t-hamano, the performance test CI job outputs the results, but it's not as reliable as CodeVitals - https://github.com/WordPress/gutenberg/actions/runs/18337000307. You can also run tests locally for debugging - |
… API (WordPress#72126) * Block Comments: Highlight block with new toggleBlockCommentSelected private API * Rename * Combine useDispatch * Update Comment * Use correct CSS selector * Change conditions for disabling spotlight * Allow changing text selection for spotlighted block without removing spotlight Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org> Co-authored-by: jarekmorawski <jarekmorawski@git.wordpress.org> Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>


Closes #71891
What? Why?
This PR highlights the block when a block comment is selected, regardless of whether Spotlight mode is enabled or not.
Currently, blocks with comments are highlighted in two ways:
selectBlockaction with its second parameter set tonull.toggleBlockHighlightaction.To make the blocks linked to the comment more prominent, this PR makes other blocks opaque, similar to Spotlight mode.
How?
toggleBlockCommentSelectedtoggleBlockSpotlightaction andisBlockCommentSelectedhasBlockSpotlightselector.toggleBlockCommentSelectedtoggleBlockSpotlightwhen a comment is selected. Blocks with selected comments are given theis-block-comment-selectedCSS class.Testing Instructions
Screenshots or screencast
9c717b808f45c6d36ca66a13e3aa0e9f.1.mp4