Writing Flow: Fix format toolbar not appearing when selecting text from block edge#77136
Writing Flow: Fix format toolbar not appearing when selecting text from block edge#77136
Conversation
When using the Top Toolbar setting, highlighting text starting from the left edge of a paragraph (on the block wrapper padding) did not show Bold/Italic formatting options. This happened because the RichText element never received focus when the drag started outside its contentEditable boundary, so its selection handlers never fired and the store was missing the attributeKey needed for isSelected. Update useSelectionObserver to detect non-collapsed selections within a RichText element that doesn't have focus, and dispatch a full selectionChange with the proper attributeKey and offsets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…edge Verifies that Bold and other formatting options appear in the Top Toolbar when the user starts a text selection from just outside the contentEditable boundary (the block wrapper padding) and drags into the paragraph text. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2edd798 to
54f148e
Compare
|
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: +89 B (0%) Total Size: 7.74 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in 54f148e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24129088666
|
Mamaduka
left a comment
There was a problem hiding this comment.
Could be a regression after refactoring in #47525.
- All these nested conditions are becoming hard to follow; maybe we could simplify them if possible.
- The fix resembles logic in the next block-scope. Do we need a reusable abstraction?
| editor, | ||
| page, | ||
| } ) => { | ||
| await editor.setIsFixedToolbar( true ); |
There was a problem hiding this comment.
Does this only happen with a fixed toolbar, or are we just trying to match the issue report?
What?
This PR fixes format toolbar not appearing when selecting text from either of the block edges.
Why?
Highlighting text starting from the left edge of a paragraph (on the block wrapper padding) did not show the formatting options in the top toolbar. This happened because the
RichTextelement never received focus when the drag started outside itscontentEditableboundary, so its selection handlers never fired.Fixes #77133.
How?
This PR updates
useSelectionObserverto detect non-collapsed selections within an unfocusedRichTextand dispatch a fullselectionChange.Testing Instructions
Testing Instructions for Keyboard
Same
Screenshots or screencast
Before:
Screen.Recording.2026-04-08.at.12.22.36.mov
After:
Screen.Recording.2026-04-08.at.12.38.56.mov
Use of AI Tools
I used Claude Code with Opus 4.6 and verified the changes manually.