Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/components/device/LogPane.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memo, useEffect, useRef, useState } from "react";
import { memo, useLayoutEffect, useRef, useState } from "react";
import { logText, type LogLine } from "../../lib/device/state";

export interface LogPaneProps {
Expand All @@ -19,8 +19,13 @@ export const LogPane = memo(function LogPane({ log, onClear, tool = "minipro" }:
const linesRef = useRef<HTMLDivElement>(null);
const [copy, setCopy] = useState<CopyState>("idle");

// Follow the newest line.
useEffect(() => {
// Follow the newest line, before the browser paints, so a change and the
// scroll that goes with it are drawn together. With the scroll after the
// paint, the app's WebKit could leave the whole box undrawn until it was
// scrolled by hand, after an update that rewrote every line and moved the
// log at once: turning "Hide file paths" on or off with Inspect's strings
// open. Chromium never did it.
useLayoutEffect(() => {
const lines = linesRef.current;
if (lines) lines.scrollTop = lines.scrollHeight;
}, [log]);
Expand Down
Loading