Skip to content

Fix scroll appearing on split view with annotations#516

Merged
amadeus merged 1 commit intopierrecomputer:mainfrom
jonatanklosko:jk-scroll
Apr 17, 2026
Merged

Fix scroll appearing on split view with annotations#516
amadeus merged 1 commit intopierrecomputer:mainfrom
jonatanklosko:jk-scroll

Conversation

@jonatanklosko
Copy link
Copy Markdown
Contributor

@jonatanklosko jonatanklosko commented Apr 17, 2026

When using split-view and annotations, the annotation content width is overestimated by 1px leading to unnecessary scroll.

Before

(Note the horizontal scroll at the bottom)

image

After

image

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 17, 2026

@jonatanklosko is attempting to deploy a commit to the Pierre Computer Company Team on Vercel.

A member of the Team first needs to authorize it.

Comment on lines -221 to +220
const update: CodeColumnUpdate = [target, specs.inlineSize];
const update: CodeColumnUpdate = [target, contentBoxSize[0].inlineSize];
Copy link
Copy Markdown
Contributor Author

@jonatanklosko jonatanklosko Apr 17, 2026

Choose a reason for hiding this comment

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

This is only relevant in split view, where each data-code has 1px border:

[data-diff-type='split'][data-overflow='scroll'] {
display: grid;
grid-template-columns: 1fr 1fr;
[data-additions] {
border-left: 1px solid var(--diffs-bg);
}
[data-deletions] {
border-right: 1px solid var(--diffs-bg);
}
}

That border would be included in the measured size here. Later we compute the annotation content width as inlineSize - item.numberWidth:

const targetWidth = Math.max(inlineSize - item.numberWidth, 0);
item.codeWidth = inlineSize === 0 ? 'auto' : inlineSize;
item.codeElement.style.setProperty(
'--diffs-column-content-width',
`${targetWidth > 0 ? `${targetWidth}px` : 'auto'}`
);
item.codeElement.style.setProperty(
'--diffs-column-width',
`${typeof item.codeWidth === 'number' ? `${item.codeWidth}px` : 'auto'}`
);

We want to exclude the border from inlineSize, which we effectively do by using contentBoxSize here (instead of subtracting something hardcoded).

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 17, 2026

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

Project Deployment Actions Updated (UTC)
pierrejs-diff-demo Ready Ready Preview Apr 17, 2026 10:31pm
pierrejs-docs Ready Ready Preview Apr 17, 2026 10:31pm

Request Review

@amadeus amadeus merged commit 16a26a2 into pierrecomputer:main Apr 17, 2026
10 checks passed
@amadeus
Copy link
Copy Markdown
Member

amadeus commented Apr 17, 2026

good catch, nice clean fix, thanks!

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