fix(webui): stabilize transcript while typing multiline drafts
This commit is contained in:
1 parent
28f6c26946
commit
fd30fda8a2
4 files changed
+167
-86
No files matched your search
@@ -0,0 +1,134 @@
|
|||||||
|
import { expect, test, type Page } from "@playwright/test";
|
||||||
|
import { canonicalThreadPayload } from "../src/tests/thread-test-payload";
|
||||||
|
|
||||||
|
const history = canonicalThreadPayload({
|
||||||
|
schemaVersion: 3,
|
||||||
|
messages: [
|
||||||
|
{ id: "question", role: "user", content: "Explain stable layout.", createdAt: 1_700_000_000_000 },
|
||||||
|
{
|
||||||
|
id: "answer", role: "assistant", createdAt: 1_700_000_001_000,
|
||||||
|
content: Array.from({ length: 25 }, (_, index) =>
|
||||||
|
`## Section ${index + 1}\n\nA completed answer stays in place while the next draft is edited. 中文与 English 混排,保持阅读位置稳定。`,
|
||||||
|
).join("\n\n"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
async function openThread(page: Page) {
|
||||||
|
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
|
||||||
|
await page.route("**/api/commands", route => route.fulfill({ json: { commands: [] } }));
|
||||||
|
await page.route("**/api/sessions/*/webui-thread?*", route => route.fulfill({ json: history }));
|
||||||
|
await page.goto("/browser/fixture.html?case=thread-loading");
|
||||||
|
await expect(page.getByRole("heading", { name: "Section 25", exact: true })).toBeVisible();
|
||||||
|
await page.evaluate(() => document.fonts.ready);
|
||||||
|
const input = page.getByRole("textbox", { name: "Message input", exact: true });
|
||||||
|
await input.fill("Next steps:\n1. Check layout\n2. ");
|
||||||
|
await input.focus();
|
||||||
|
const scroller = page.getByTestId("thread-message-region");
|
||||||
|
await expect.poll(() => scroller.evaluate(node => node.scrollHeight - node.clientHeight - node.scrollTop)).toBeLessThanOrEqual(1);
|
||||||
|
return { input, scroller };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sampleWhileTyping(page: Page) {
|
||||||
|
return page.evaluate(async () => {
|
||||||
|
const scroller = document.querySelector<HTMLElement>(".thread-message-viewport")!;
|
||||||
|
const input = document.querySelector<HTMLTextAreaElement>("textarea")!;
|
||||||
|
const baseline = { top: scroller.scrollTop, inputHeight: input.clientHeight, viewportHeight: scroller.clientHeight };
|
||||||
|
const samples: typeof baseline[] = [];
|
||||||
|
let active = true;
|
||||||
|
const sample = () => {
|
||||||
|
samples.push({ top: scroller.scrollTop, inputHeight: input.clientHeight, viewportHeight: scroller.clientHeight });
|
||||||
|
if (active) requestAnimationFrame(sample);
|
||||||
|
};
|
||||||
|
requestAnimationFrame(sample);
|
||||||
|
return new Promise<{ baseline: typeof baseline; samples: typeof samples }>(resolve => {
|
||||||
|
document.addEventListener("typing-sample-end", async () => {
|
||||||
|
await new Promise(requestAnimationFrame);
|
||||||
|
active = false;
|
||||||
|
resolve({ baseline, samples });
|
||||||
|
}, { once: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const width of [1500, 390]) for (const readingHistory of [false, true]) {
|
||||||
|
test(`typing preserves every rendered transcript position at ${width}px ${readingHistory ? "in history" : "at the tail"}`, async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width, height: 940 });
|
||||||
|
const { input, scroller } = await openThread(page);
|
||||||
|
if (readingHistory) {
|
||||||
|
const box = (await scroller.boundingBox())!;
|
||||||
|
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
|
||||||
|
await page.mouse.wheel(0, -350);
|
||||||
|
await expect.poll(() => scroller.evaluate(node => node.scrollHeight - node.clientHeight - node.scrollTop)).toBeGreaterThan(300);
|
||||||
|
}
|
||||||
|
const sampling = sampleWhileTyping(page);
|
||||||
|
await input.pressSequentially("abcdefghijklmnopqrstuvwxyz", { delay: 75 });
|
||||||
|
await page.evaluate(() => document.dispatchEvent(new Event("typing-sample-end")));
|
||||||
|
const { baseline, samples } = await sampling;
|
||||||
|
expect(samples.length).toBeGreaterThan(10);
|
||||||
|
expect(Math.max(...samples.map(sample => Math.abs(sample.top - baseline.top)))).toBeLessThanOrEqual(1);
|
||||||
|
expect(samples.every(sample => sample.inputHeight === baseline.inputHeight && sample.viewportHeight === baseline.viewportHeight)).toBe(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
test("autosizing still grows, caps and shrinks the real input", async ({ page }) => {
|
||||||
|
const { input, scroller } = await openThread(page);
|
||||||
|
const initialHeight = await input.evaluate(node => node.clientHeight);
|
||||||
|
await input.fill(Array.from({ length: 6 }, (_, index) => `Line ${index + 1}`).join("\n"));
|
||||||
|
await expect.poll(() => input.evaluate(node => node.clientHeight)).toBeGreaterThan(initialHeight);
|
||||||
|
expect(await input.evaluate(node => node.scrollHeight <= node.clientHeight + 1)).toBe(true);
|
||||||
|
await input.fill(Array.from({ length: 20 }, (_, index) => `Line ${index + 1}`).join("\n"));
|
||||||
|
await expect(input).toHaveCSS("height", "260px");
|
||||||
|
expect(await input.evaluate(node => node.scrollHeight > node.clientHeight)).toBe(true);
|
||||||
|
await input.press("Control+End");
|
||||||
|
await expect.poll(() => input.evaluate(node => node.scrollTop)).toBeGreaterThan(0);
|
||||||
|
await input.fill("Short draft");
|
||||||
|
await expect.poll(() => input.evaluate(node => node.clientHeight)).toBeLessThan(initialHeight);
|
||||||
|
expect(await input.evaluate(node => node.scrollHeight <= node.clientHeight + 1)).toBe(true);
|
||||||
|
await expect.poll(() => scroller.evaluate(node => node.scrollHeight - node.clientHeight - node.scrollTop)).toBeLessThanOrEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Chromium IME composition and commit keep the transcript stationary", async ({ page }) => {
|
||||||
|
const { input } = await openThread(page);
|
||||||
|
const original = await input.inputValue();
|
||||||
|
const cdp = await page.context().newCDPSession(page);
|
||||||
|
const sampling = sampleWhileTyping(page);
|
||||||
|
for (const text of ["z", "zhong", "zhongwen"]) {
|
||||||
|
await cdp.send("Input.imeSetComposition", { text, selectionStart: text.length, selectionEnd: text.length });
|
||||||
|
await page.evaluate(() => new Promise(requestAnimationFrame));
|
||||||
|
}
|
||||||
|
await expect(input).toHaveValue(`${original}zhongwen`);
|
||||||
|
await cdp.send("Input.insertText", { text: "中文" });
|
||||||
|
await expect(input).toHaveValue(`${original}中文`);
|
||||||
|
await page.evaluate(() => document.dispatchEvent(new Event("typing-sample-end")));
|
||||||
|
const { baseline, samples } = await sampling;
|
||||||
|
expect(samples.length).toBeGreaterThan(0);
|
||||||
|
expect(Math.max(...samples.map(sample => Math.abs(sample.top - baseline.top)))).toBeLessThanOrEqual(1);
|
||||||
|
expect(samples.every(sample => sample.inputHeight === baseline.inputHeight)).toBe(true);
|
||||||
|
await cdp.detach();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test("multiline drafts resize after reading typography changes", async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||||
|
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
|
||||||
|
await page.goto("/browser/fixture.html?case=typography");
|
||||||
|
const input = page.getByRole("textbox", { name: "Message input", exact: true });
|
||||||
|
await input.fill("First line\nSecond line\nThird line");
|
||||||
|
const standardHeight = await input.evaluate(node => node.clientHeight);
|
||||||
|
const sizes = [
|
||||||
|
["large", "Large reading text", 20],
|
||||||
|
["small", "Small reading text", 16],
|
||||||
|
["standard", "Standard reading text", 18],
|
||||||
|
] as const;
|
||||||
|
for (const [size, label, fontSize] of sizes) {
|
||||||
|
await page.getByRole("radio", { name: label, exact: true }).click();
|
||||||
|
await expect(page.locator("html")).toHaveAttribute("data-reading-text-size", size);
|
||||||
|
await expect(input).toHaveCSS("font-size", `${fontSize}px`);
|
||||||
|
expect(await input.evaluate(node => node.scrollHeight <= node.clientHeight + 1)).toBe(true);
|
||||||
|
const height = await input.evaluate(node => node.clientHeight);
|
||||||
|
if (size === "large") expect(height).toBeGreaterThan(standardHeight);
|
||||||
|
else if (size === "small") expect(height).toBeLessThan(standardHeight);
|
||||||
|
else expect(height).toBe(standardHeight);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1024,6 +1024,20 @@ function GoalStateStrip({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function autosizeTextarea(input: HTMLTextAreaElement) {
|
||||||
|
const container = input.parentElement!;
|
||||||
|
const previousMinHeight = container.style.minHeight;
|
||||||
|
// Measuring the one-row textarea must not expand the sibling transcript and
|
||||||
|
// clamp its native scroll offset, even temporarily before paint.
|
||||||
|
container.style.minHeight = `${container.getBoundingClientRect().height}px`;
|
||||||
|
try {
|
||||||
|
input.style.height = "auto";
|
||||||
|
input.style.height = `${Math.min(input.scrollHeight, 260)}px`;
|
||||||
|
} finally {
|
||||||
|
container.style.minHeight = previousMinHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function ThreadComposer({
|
export function ThreadComposer({
|
||||||
onSend,
|
onSend,
|
||||||
disabled,
|
disabled,
|
||||||
@@ -1130,10 +1144,7 @@ export function ThreadComposer({
|
|||||||
previousWidth = width;
|
previousWidth = width;
|
||||||
setCompactControls(width <= 512);
|
setCompactControls(width <= 512);
|
||||||
const input = textareaRef.current;
|
const input = textareaRef.current;
|
||||||
if (input) {
|
if (input) autosizeTextarea(input);
|
||||||
input.style.height = "auto";
|
|
||||||
input.style.height = `${Math.min(input.scrollHeight, 260)}px`;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
update();
|
update();
|
||||||
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
|
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
|
||||||
@@ -1735,27 +1746,22 @@ export function ThreadComposer({
|
|||||||
};
|
};
|
||||||
}, [filteredMentionCandidates.length, filteredSlashCommands.length, showAnyPalette]);
|
}, [filteredMentionCandidates.length, filteredSlashCommands.length, showAnyPalette]);
|
||||||
|
|
||||||
const resizeTextarea = useCallback((restoreFocus = true) => {
|
const focusTextarea = useCallback(() => {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => textareaRef.current?.focus());
|
||||||
const el = textareaRef.current;
|
|
||||||
if (!el) return;
|
|
||||||
el.style.height = "auto";
|
|
||||||
el.style.height = `${Math.min(el.scrollHeight, 260)}px`;
|
|
||||||
if (restoreFocus) el.focus();
|
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const el = textareaRef.current;
|
const el = textareaRef.current;
|
||||||
if (!el || mentionInput.isComposing) return;
|
if (!el || mentionInput.isComposing) return;
|
||||||
el.style.height = "auto";
|
autosizeTextarea(el);
|
||||||
el.style.height = `${Math.min(el.scrollHeight, 260)}px`;
|
|
||||||
if (mentionOverlayRef.current) mentionOverlayRef.current.scrollTop = el.scrollTop;
|
if (mentionOverlayRef.current) mentionOverlayRef.current.scrollTop = el.scrollTop;
|
||||||
}, [compactControls, mentionInput.isComposing, mentionInput.value]);
|
}, [compactControls, mentionInput.isComposing, mentionInput.value]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
resizeTextarea(false);
|
// The parent projects typography tokens in its layout effect; measure after it.
|
||||||
}, [readingTextSize, resizeTextarea]);
|
const input = textareaRef.current;
|
||||||
|
if (input) autosizeTextarea(input);
|
||||||
|
}, [readingTextSize]);
|
||||||
|
|
||||||
// Runs before paint so switching sessions never flashes stale draft text.
|
// Runs before paint so switching sessions never flashes stale draft text.
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
@@ -1768,12 +1774,6 @@ export function ThreadComposer({
|
|||||||
setCliAppMenuDismissed(false);
|
setCliAppMenuDismissed(false);
|
||||||
setCursorPosition(0);
|
setCursorPosition(0);
|
||||||
clear();
|
clear();
|
||||||
requestAnimationFrame(() => {
|
|
||||||
const el = textareaRef.current;
|
|
||||||
if (!el) return;
|
|
||||||
el.style.height = "auto";
|
|
||||||
el.style.height = `${Math.min(el.scrollHeight, 260)}px`;
|
|
||||||
});
|
|
||||||
}, [clear, pendingQueueKey]);
|
}, [clear, pendingQueueKey]);
|
||||||
|
|
||||||
const appendTranscription = useCallback((text: string) => {
|
const appendTranscription = useCallback((text: string) => {
|
||||||
@@ -1788,8 +1788,8 @@ export function ThreadComposer({
|
|||||||
setSlashMenuDismissed(false);
|
setSlashMenuDismissed(false);
|
||||||
setCliAppMenuDismissed(false);
|
setCliAppMenuDismissed(false);
|
||||||
setInlineError(null);
|
setInlineError(null);
|
||||||
resizeTextarea();
|
focusTextarea();
|
||||||
}, [resizeTextarea]);
|
}, [focusTextarea]);
|
||||||
|
|
||||||
const clearVoiceErrorTimers = useCallback(() => {
|
const clearVoiceErrorTimers = useCallback(() => {
|
||||||
if (voiceErrorFadeTimerRef.current !== null) clearTimeout(voiceErrorFadeTimerRef.current);
|
if (voiceErrorFadeTimerRef.current !== null) clearTimeout(voiceErrorFadeTimerRef.current);
|
||||||
@@ -1872,7 +1872,7 @@ export function ThreadComposer({
|
|||||||
setSlashMenuDismissed(true);
|
setSlashMenuDismissed(true);
|
||||||
setCliAppMenuDismissed(false);
|
setCliAppMenuDismissed(false);
|
||||||
setInlineError(null);
|
setInlineError(null);
|
||||||
resizeTextarea();
|
focusTextarea();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1895,9 +1895,9 @@ export function ThreadComposer({
|
|||||||
setSlashMenuDismissed(true);
|
setSlashMenuDismissed(true);
|
||||||
setCliAppMenuDismissed(false);
|
setCliAppMenuDismissed(false);
|
||||||
setInlineError(null);
|
setInlineError(null);
|
||||||
resizeTextarea();
|
focusTextarea();
|
||||||
},
|
},
|
||||||
[handleStop, isStreaming, onStop, recentSlashCommands, replaceMentionInput, resizeTextarea, skillQuery, value],
|
[handleStop, isStreaming, onStop, recentSlashCommands, replaceMentionInput, focusTextarea, skillQuery, value],
|
||||||
);
|
);
|
||||||
|
|
||||||
const insertMention = useCallback(
|
const insertMention = useCallback(
|
||||||
@@ -1907,9 +1907,9 @@ export function ThreadComposer({
|
|||||||
setCliAppMenuDismissed(true);
|
setCliAppMenuDismissed(true);
|
||||||
setSlashMenuDismissed(false);
|
setSlashMenuDismissed(false);
|
||||||
setInlineError(null);
|
setInlineError(null);
|
||||||
resizeTextarea();
|
focusTextarea();
|
||||||
},
|
},
|
||||||
[replaceMentionInput, resizeTextarea, value],
|
[replaceMentionInput, focusTextarea, value],
|
||||||
);
|
);
|
||||||
|
|
||||||
const chooseMentionCandidate = useCallback(
|
const chooseMentionCandidate = useCallback(
|
||||||
@@ -1982,8 +1982,8 @@ export function ThreadComposer({
|
|||||||
setSlashMenuDismissed(false);
|
setSlashMenuDismissed(false);
|
||||||
setCliAppMenuDismissed(false);
|
setCliAppMenuDismissed(false);
|
||||||
setCursorPosition(0);
|
setCursorPosition(0);
|
||||||
resizeTextarea(restoreFocus);
|
if (restoreFocus) focusTextarea();
|
||||||
}, [resizeTextarea]);
|
}, [focusTextarea]);
|
||||||
|
|
||||||
const queuedPromptError = useCallback((prompt: QueuedPrompt): string | null => {
|
const queuedPromptError = useCallback((prompt: QueuedPrompt): string | null => {
|
||||||
if (utf8Bytes(formatQuotedUserMessage(prompt.text, prompt.quotedContext)) > maxTextBytes) {
|
if (utf8Bytes(formatQuotedUserMessage(prompt.text, prompt.quotedContext)) > maxTextBytes) {
|
||||||
@@ -2053,8 +2053,8 @@ export function ThreadComposer({
|
|||||||
} else {
|
} else {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
resizeTextarea();
|
focusTextarea();
|
||||||
}, [clear, collectGuidancePrompt, hasComposerContent, normalizedQuotedContext, onQuotedContextChange, replaceMentionInput, resizeTextarea, restoreReadyImages, setQueuedPrompt]);
|
}, [clear, collectGuidancePrompt, hasComposerContent, normalizedQuotedContext, onQuotedContextChange, replaceMentionInput, focusTextarea, restoreReadyImages, setQueuedPrompt]);
|
||||||
|
|
||||||
const sendQueuedPrompt = useCallback(
|
const sendQueuedPrompt = useCallback(
|
||||||
(prompt: QueuedPrompt, extraOptions?: SendOptions) => {
|
(prompt: QueuedPrompt, extraOptions?: SendOptions) => {
|
||||||
@@ -2337,13 +2337,6 @@ export function ThreadComposer({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onInput: React.FormEventHandler<HTMLTextAreaElement> = (e) => {
|
|
||||||
if ((e.nativeEvent as InputEvent).isComposing) return;
|
|
||||||
const el = e.currentTarget;
|
|
||||||
el.style.height = "auto";
|
|
||||||
el.style.height = `${Math.min(el.scrollHeight, 260)}px`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const onFilePick: React.ChangeEventHandler<HTMLInputElement> = (e) => {
|
const onFilePick: React.ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||||
const files = Array.from(e.target.files ?? []);
|
const files = Array.from(e.target.files ?? []);
|
||||||
e.target.value = "";
|
e.target.value = "";
|
||||||
@@ -2665,7 +2658,6 @@ export function ThreadComposer({
|
|||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
secondEnterPromptIdRef.current = null;
|
secondEnterPromptIdRef.current = null;
|
||||||
}}
|
}}
|
||||||
onInput={onInput}
|
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
onKeyUp={() => setCursorPosition(rawSelection().start)}
|
onKeyUp={() => setCursorPosition(rawSelection().start)}
|
||||||
onSelect={() => setCursorPosition(rawSelection().start)}
|
onSelect={() => setCursorPosition(rawSelection().start)}
|
||||||
|
|||||||
@@ -299,7 +299,6 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
|||||||
const restoreScrollAfterPrependRef =
|
const restoreScrollAfterPrependRef =
|
||||||
useRef<{ height: number; top: number } | null>(null);
|
useRef<{ height: number; top: number } | null>(null);
|
||||||
const historyScrollAnchorRef = useRef<HistoryScrollAnchor | null>(null);
|
const historyScrollAnchorRef = useRef<HistoryScrollAnchor | null>(null);
|
||||||
const composerInputScrollTopRef = useRef<number | null>(null);
|
|
||||||
const composerDockHeightRef = useRef(0);
|
const composerDockHeightRef = useRef(0);
|
||||||
const [atBottom, setAtBottom] = useState(true);
|
const [atBottom, setAtBottom] = useState(true);
|
||||||
const [atHistoryTop, setAtHistoryTop] = useState(false);
|
const [atHistoryTop, setAtHistoryTop] = useState(false);
|
||||||
@@ -1116,23 +1115,9 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
|||||||
data-testid="thread-composer-dock"
|
data-testid="thread-composer-dock"
|
||||||
onInputCapture={(event) => {
|
onInputCapture={(event) => {
|
||||||
if (event.target instanceof HTMLTextAreaElement) {
|
if (event.target instanceof HTMLTextAreaElement) {
|
||||||
composerInputScrollTopRef.current = scrollRef.current?.scrollTop ?? null;
|
|
||||||
threadMotionRef.current?.handleComposerInput();
|
threadMotionRef.current?.handleComposerInput();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onInput={(event) => {
|
|
||||||
if (!(event.target instanceof HTMLTextAreaElement)) return;
|
|
||||||
const previousScrollTop = composerInputScrollTopRef.current;
|
|
||||||
composerInputScrollTopRef.current = null;
|
|
||||||
const scrollEl = scrollRef.current;
|
|
||||||
if (scrollEl && previousScrollTop !== null) {
|
|
||||||
// Textarea autosizing briefly collapses to `height: auto` while
|
|
||||||
// measuring. Chrome can clamp the sibling thread scrollport in
|
|
||||||
// that intermediate layout; restore it before paint, then let
|
|
||||||
// ResizeObserver handle any real final composer height change.
|
|
||||||
scrollEl.scrollTop = previousScrollTop;
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className={cn(
|
className={cn(
|
||||||
"row-start-2 z-10 w-full",
|
"row-start-2 z-10 w-full",
|
||||||
hasThreadLayout ? "thread-composer-dock relative" : "relative self-center",
|
hasThreadLayout ? "thread-composer-dock relative" : "relative self-center",
|
||||||
|
|||||||
@@ -1234,36 +1234,6 @@ describe("ThreadViewport", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("restores thread scroll after the textarea autosize measurement collapses it", () => {
|
|
||||||
let scroller: HTMLElement | null = null;
|
|
||||||
const { container } = render(
|
|
||||||
<ThreadViewport
|
|
||||||
messages={messages}
|
|
||||||
isStreaming={false}
|
|
||||||
composer={(
|
|
||||||
<textarea
|
|
||||||
aria-label="Message input"
|
|
||||||
onInput={() => {
|
|
||||||
if (scroller) scroller.scrollTop = 692;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
scroller = getScroller(container);
|
|
||||||
Object.defineProperty(scroller, "scrollTop", {
|
|
||||||
configurable: true,
|
|
||||||
writable: true,
|
|
||||||
value: 700,
|
|
||||||
});
|
|
||||||
|
|
||||||
fireEvent.input(screen.getByLabelText("Message input"), {
|
|
||||||
target: { value: "中文" },
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(scroller.scrollTop).toBe(700);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("keeps the thread scrollport above a mobile soft keyboard", async () => {
|
it("keeps the thread scrollport above a mobile soft keyboard", async () => {
|
||||||
const visualViewport = stubVisualViewport({ innerHeight: 800, height: 480 });
|
const visualViewport = stubVisualViewport({ innerHeight: 800, height: 480 });
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in new issue
Block a user