Conversation
This update introduces a new feature that keeps selection toolbars fixed while formatting operations alter the geometry of selected content. Additionally, it includes a test to ensure the selection toolbar remains stationary across document commits. The `useSelectionToolbar` hook has been modified to maintain the captured rect during formatting, preventing toolbar movement during the same selection. Key changes: - New test case for fixed selection toolbar behavior. - Adjustments to `useSelectionToolbar` to preserve toolbar position during formatting. - Added documentation for the new feature in the changeset.
…nges" This reverts commit dafc609.
This update introduces a feature that allows selection toolbars to be anchored to stable selection edges with horizontal alignment options (left, center, right). The `useSelectionToolbar` hook has been modified to remeasure the toolbar's position after document commits, ensuring accurate placement during formatting changes. Additionally, tests have been added to verify the toolbar's behavior with live geometry adjustments. Key changes: - New horizontal alignment options for selection toolbars. - Updates to `useSelectionToolbar` for live geometry measurement. - Enhanced tests for toolbar positioning and alignment behavior.
This commit introduces a new test case that verifies the behavior of the selection toolbar when the native selection is collapsed. The test ensures that the toolbar correctly uses the editor's selection geometry to position itself accurately. Additionally, the `useSelectionToolbar` hook has been updated to handle cases where the selection range is collapsed, returning null for the bounding rectangle in such scenarios. Key changes: - New test for handling collapsed native selection in the selection toolbar. - Updates to `useSelectionToolbar` to return null for collapsed selections.
Member
Author
|
bugbot run |
1 similar comment
Member
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 4c475f6. Configure here.
janglad
requested review from
MatteoGauthier,
krijnrijshouwer and
noudadrichem
September 22, 2026 14:13
janglad
deleted the
fix/web-3984-editor-floating-formatting-bar-jumps-when-text-width-changes
branch
September 22, 2026 14:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Before
(notice: micro jumps of bar on bold, wrong positioning on alignment)
Screen.Recording.2026-09-22.at.14.35.05.mov
Cause
After
Screen.Recording.2026-09-22.at.14.34.40.mov
New behavior
Note
Low Risk
UI-only positioning changes in the selection toolbar with added tests; no auth, data, or document mutation behavior changes.
Overview
Fixes floating selection toolbar jumps and wrong first paint by remeasuring selection geometry after layout and re-reading it when positioning the toolbar.
useSelectionToolbarnow bumps a revision on selection, commit, scroll, and resize, applies rect updates inuseIsomorphicLayoutEffect, exportsresolveSelectionToolbarRect, and ignores collapsed native DOM ranges so placement can fall back to editor geometry when the browser selection is transient.SelectionToolbar.ContentaddshorizontalAlign(left|center|right) so hosts can pin the bar to a stable selection edge when width changes (e.g. bold), and computes position from live geometry during the pre-paint layout pass instead of a stale commit rect—so RTL/alignment updates land on the first interaction.Tests cover collapsed-native fallback, stale measurements, left-anchor stability across width changes, and scroll repositioning; the React package spec and changeset document the new API.
Reviewed by Cursor Bugbot for commit 4c475f6. Bugbot is set up for automated code reviews on this repo. Configure here.