Skip to content

Position the editor caret against its overlay root - #64

Merged
MatteoGauthier merged 4 commits into
mainfrom
fix/web-4122-pen-textarea-caret-is-not-visible-in-modal
Sep 25, 2026
Merged

MatteoGauthier merged 4 commits into
mainfrom
fix/web-4122-pen-textarea-caret-is-not-visible-in-modal

Conversation

@MatteoGauthier

@MatteoGauthier MatteoGauthier commented Sep 24, 2026 •

Copy link
Copy Markdown
Member
  • Position the editor caret against its overlay root

Note

Low Risk
Localized caret overlay layout change with updated unit tests; no auth, data, or document-model impact.

Overview
Fixes the custom editor caret disappearing in modals and other hosts where filtered or transformed ancestors break position: fixed placement.

Pen.Editor.CaretOverlay now anchors the caret with position: absolute on a position: relative overlay root. Caret geometry still comes from GeometryReader, but left/top subtract the overlay’s bounding box (read in the same measureWithRoot pass as the caret rect) so the caret tracks the text instead of the viewport.

Tests assert overlay-relative coordinates; the React spec and changeset describe the behavior; readCaretRect is allowlisted for the overlay-origin DOM read.

Reviewed by Cursor Bugbot for commit 6197b8c. Bugbot is set up for automated code reviews on this repo. Configure here.

- Anchor the caret absolutely to the overlay so a filtered or transformed ancestor is not its containing block.
- Subtract the overlay origin from the caret rect in the same scheduled measure.
- Record readCaretRect on the unscheduled-measure allowlist because GeometryReader does not own the overlay box.
- Normalize the neighboring allowlist entry to spaces.
- Stub a non-zero overlay origin and assert absolute left and top offsets.
- State in the React spec that filtered or transformed ancestors do not become the caret's containing block.
- Add a patch changeset for @input/pen-react.
@MatteoGauthier

Copy link
Copy Markdown
Member Author

bugbot run

@cursor

cursor Bot commented Sep 24, 2026

Copy link
Copy Markdown

Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings.

@MatteoGauthier

Copy link
Copy Markdown
Member Author

bugbot run

@MatteoGauthier MatteoGauthier changed the title fix/web 4122 pen textarea caret is not visible in modal WEB-4122: Pen: Textarea caret is not visible in modal Sep 24, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 6197b8c. Configure here.

@MatteoGauthier
MatteoGauthier marked this pull request as ready for review September 24, 2026 14:24
@MatteoGauthier MatteoGauthier changed the title WEB-4122: Pen: Textarea caret is not visible in modal Position the editor caret against its overlay root Sep 24, 2026
@MatteoGauthier
MatteoGauthier merged commit 194d37c into main Sep 25, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants