fix(desktop): stabilize virtual spacers at fractional zoom (#1428)

This commit is contained in:
程序员阿江-Relakkes
2026-10-03 20:22:42 +08:00
committed by GitHub
parent 363e59dda9
commit fa28fb8b21
2 changed files with 21 additions and 1 deletions
@@ -1967,6 +1967,19 @@ describe('MessageList nested tool calls', () => {
expect(firstTopChunk.style.contentVisibility).toBe('auto')
expect(firstTopChunk.style.containIntrinsicSize).toMatch(/^0 \d+px$/)
// At native 80% zoom, each chunk's layout rounding accumulates. The outer
// box must own the requested total, or switching a virtual boundary can
// change scrollHeight by ~20px and trigger another native scroll event.
for (const position of ['top', 'bottom']) {
const spacer = container.querySelector<HTMLElement>(`[data-virtual-spacer="${position}"]`)!
const requestedHeight = Array.from(spacer.children).reduce(
(total, chunk) => total + Number.parseFloat((chunk as HTMLElement).style.height),
0,
)
expect(Number.parseFloat(spacer.style.height)).toBeCloseTo(requestedHeight, 6)
expect(spacer.classList.contains('overflow-hidden')).toBe(true)
}
// Items inside the active window must NOT carry content-visibility (this
// is the regression guard that previous content-visibility rollout hit).
const visibleItems = container.querySelectorAll('[data-virtual-message-item]')
+8 -1
View File
@@ -2181,7 +2181,14 @@ function VirtualSpacer({ height, position }: { height: number; position: 'top' |
}
return (
<div data-virtual-spacer={position} aria-hidden="true">
<div
data-virtual-spacer={position}
aria-hidden="true"
className="overflow-hidden"
// Fractional zoom rounds each chunk independently. Keep their accumulated
// error out of scrollHeight so native scrolling cannot toggle the window.
style={{ height }}
>
{chunks.map((chunk) => (
<div
key={chunk.key}