Skip to content

fix(diffs): Wrap annotation content in every overflow mode - #1021

Merged
necolas merged 1 commit into
mainfrom
fix-annotation-whitespace-wrap
Jul 23, 2026
Merged

fix(diffs): Wrap annotation content in every overflow mode#1021
necolas merged 1 commit into
mainfrom
fix-annotation-whitespace-wrap

Conversation

@necolas

@necolas necolas commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Annotation prose did not wrap in the default scroll overflow mode. React consumers had to add white-space: normal to each annotation by hand, or the text overflowed the diff column.

The diffs stylesheet lives in the shadow root, so slotted annotation content gets its white-space by inheritance from the shadow-DOM [data-annotation-content] parent. That parent normalized white-space only under [data-overflow="wrap"]. In scroll mode it inherited white-space: pre from the pre element, so the slotted prose did not wrap.

Set white-space: normal on [data-annotation-content] in every overflow mode. Annotations hold prose, not code, so they never need pre. One rule fixes every render path (React, imperative, SSR) and keeps them consistent.

Also remove the now-unnecessary white-space: normal workaround from the docs annotations demo, and add a browser regression test for the computed white-space in scroll mode.

Annotation prose did not wrap in the default scroll overflow mode.
React consumers had to add `white-space: normal` to each annotation by
hand, or the text overflowed the diff column.

The diffs stylesheet lives in the shadow root, so slotted annotation
content gets its white-space by inheritance from the shadow-DOM
`[data-annotation-content]` parent. That parent normalized white-space
only under `[data-overflow="wrap"]`. In scroll mode it inherited
`white-space: pre` from the `pre` element, so the slotted prose did not
wrap.

Set `white-space: normal` on `[data-annotation-content]` in every
overflow mode. Annotations hold prose, not code, so they never need
`pre`. One rule fixes every render path (React, imperative, SSR) and
keeps them consistent.

Also remove the now-unnecessary `white-space: normal` workaround from
the docs annotations demo, and add a browser regression test for the
computed white-space in scroll mode.
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pierre-docs-diffs Ready Ready Preview Jul 23, 2026 8:57pm
pierre-docs-diffshub Ready Ready Preview Jul 23, 2026 8:57pm
pierre-docs-trees Ready Ready Preview Jul 23, 2026 8:57pm
pierrejs-diff-demo Ready Ready Preview Jul 23, 2026 8:57pm

Request Review

@amadeus amadeus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good catch!

@necolas
necolas merged commit 8bf13f5 into main Jul 23, 2026
8 checks passed
@necolas
necolas deleted the fix-annotation-whitespace-wrap branch July 23, 2026 21:22
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.

2 participants