fix(app): keep the composer's last line clear of the fade (#57840)

This commit is contained in:
James Long
2026-10-21 12:26:43 -04:00
committed by GitHub
Unverified
parent 1ef252d1a4
commit 4cad28c3d5
3 changed files with 37 additions and 2 deletions
@@ -417,6 +417,33 @@ test("keeps a 25000-line crash report editable in a new session", async ({ page
await expectCaretVisible(input)
})
test("keeps a line added at the end of a scrolling prompt clear of the bottom fade", async ({ page }) => {
const { editor } = await openSession(page, { name: "ComposerFade" })
await editor.click()
for (const line of Array.from({ length: 12 }, (_, index) => `Line ${index + 1}`)) {
await page.keyboard.type(line)
await page.keyboard.press("Shift+Enter")
}
await page.keyboard.type("Last line")
await expect.poll(() => editor.innerText()).toMatch(/Line 12\nLast line$/)
// The mask fades the viewport's bottom --composer-fade-bottom pixels; the last line must end above them.
await expect
.poll(() =>
editor.evaluate((element) => {
const viewport = element.closest(".scroll-view__viewport")!
const range = document.createRange()
range.selectNodeContents(element)
const line = Array.from(range.getClientRects()).reduce((last, rect) => (rect.bottom > last.bottom ? rect : last))
const fade = parseFloat(getComputedStyle(viewport).getPropertyValue("--composer-fade-bottom"))
return Math.max(0, Math.round(line.bottom - (viewport.getBoundingClientRect().bottom - fade)))
}),
)
.toBe(0)
})
test("a key-up never moves the caret back after later navigation", async ({ page }) => {
const input = await draft(page)
await input.pressSequentially("first line")
@@ -23,6 +23,13 @@
);
}
/* Chromium reveals the caret flush with the viewport edge after Enter or typing, ignoring the editor padding, so the
last line would land under the fade. Keep revealed carets clear of both 16px fades. */
[data-component="composer-scroll"] > .scroll-view__viewport,
[data-slot="composer-content"][data-history-preview] {
scroll-padding-block: 16px;
}
/* History scrolls text and attachments together, so only the outer viewport applies the mask. */
[data-slot="composer-content"][data-history-preview] [data-component="composer-scroll"] > .scroll-view__viewport {
mask-image: none;
+3 -2
View File
@@ -380,9 +380,10 @@ export function ComposerEditor(props: ComposerEditorProps) {
if (!caret.height) return
const bounds = viewport.getBoundingClientRect()
if (caret.bottom > bounds.bottom - 8) viewport.scrollTop += caret.bottom - bounds.bottom + 8
// Matches the viewport's 16px scroll-padding, which keeps the caret clear of the fades.
if (caret.bottom > bounds.bottom - 16) viewport.scrollTop += caret.bottom - bounds.bottom + 16
if (caret.top < bounds.top + 8) viewport.scrollTop += caret.top - bounds.top - 8
if (caret.top < bounds.top + 16) viewport.scrollTop += caret.top - bounds.top - 16
})
}}
onFocus={() => props.controller.dispatch({ type: "focus.editor" })}