fix(app): keep the browser pane live while resizing panels on macOS (#64443)

This commit is contained in:
usrnk1
2026-11-17 15:27:25 +01:00
committed by GitHub
Unverified
parent ee5dfa9d41
commit 09b7b1e726
2 changed files with 42 additions and 6 deletions
@@ -10,6 +10,12 @@ const modules = {
language: source("../src/runtime/i18n/language.tsx"),
}
// Panel motion reads `navigator.platform` on each drag, so a test pins the platform whose behaviour it covers.
const pinPlatform = (page: Page, platform: string) =>
page.evaluate((value) => {
Object.defineProperty(navigator, "platform", { value, configurable: true })
}, platform)
story.beforeEach(async ({ mount, page }) => {
// Any story loads the app styles; the fixture mounts the pane beside it on the real host embeds.
await mount("ui-line-comment--editor")
@@ -107,10 +113,11 @@ story("paints a still of the page in place of the native view while a resize han
const handle = root.getByTestId("pane-resize-handle")
const native = root.getByTestId("native-Alpha")
const still = root.locator("#browser-panel img")
await pinPlatform(page, "Linux x86_64")
// A native view's bounds land on screen frames before the DOM around it, so one left up through a drag jumps against
// its pane on every move. A click on the handle moves nothing and must not blink the page out. Read in the same task
// as each event, so a view hidden and shown again before the next frame cannot pass.
// On Linux a native view's bounds land on screen frames before the DOM around it, so one left up through a drag jumps
// against its pane on every move. A click on the handle moves nothing and must not blink the page out. Read in the
// same task as each event, so a view hidden and shown again before the next frame cannot pass.
const visible = await handle.evaluate((element) => {
const read = () => document.querySelector('[data-testid="native-Alpha"]')?.getAttribute("data-visible")
const box = element.getBoundingClientRect()
@@ -137,11 +144,39 @@ story("paints a still of the page in place of the native view while a resize han
await expect(still).toHaveCount(0)
})
story("keeps the native view live while a resize handle is dragged on macOS", async ({ page }) => {
const root = page.getByTestId("browser-pane-fixture")
const handle = root.getByTestId("pane-resize-handle")
const still = root.locator("#browser-panel img")
await pinPlatform(page, "MacIntel")
// macOS puts a native view's bounds and the DOM around it on the same frame, so the page keeps laying out through the
// drag instead of freezing behind a still. Read in the same task as each move, so a blink between frames cannot pass.
const visible = await handle.evaluate((element) => {
const read = () => document.querySelector('[data-testid="native-Alpha"]')?.getAttribute("data-visible")
const box = element.getBoundingClientRect()
const at = { bubbles: true, pointerId: 1, clientX: box.x + box.width / 2, clientY: box.y + box.height / 2 }
element.dispatchEvent(new PointerEvent("pointerdown", { ...at, button: 0 }))
document.dispatchEvent(new PointerEvent("pointermove", { ...at, clientX: at.clientX - 40 }))
const dragging = read()
document.dispatchEvent(new PointerEvent("pointermove", { ...at, clientX: at.clientX - 80 }))
const moved = read()
document.dispatchEvent(new PointerEvent("pointerup", at))
return { dragging, moved }
})
expect(visible).toEqual({ dragging: "true", moved: "true" })
await expect(handle).not.toHaveAttribute("data-dragging")
await expect(still).toHaveCount(0)
})
story("shows the native view again when the window loses focus mid-drag", async ({ page }) => {
const root = page.getByTestId("browser-pane-fixture")
const handle = root.getByTestId("pane-resize-handle")
const native = root.getByTestId("native-Alpha")
const still = root.locator("#browser-panel img")
await pinPlatform(page, "Linux x86_64")
// Alt+Tab mid-drag delivers no pointerup; the page must not stay locked behind a still.
await handle.evaluate((element) => {
+4 -3
View File
@@ -15,14 +15,15 @@ import {
// panel moves.
const [flights, setFlights] = createSignal(0)
// A resize handle being dragged. A native view's bounds land on screen frames before the DOM around it, so one kept
// live through a drag would jump against its panel on every move.
// A resize handle being dragged. On Linux a native view's bounds land on screen frames before the DOM around it, so one
// kept live through a drag would jump against its panel on every move. macOS puts both on the same frame, so its views
// stay live and keep laying out through the drag. Windows is untested and keeps the still.
const [resizing, setResizing] = createSignal(false)
export const panelsMoving = () => flights() > 0 || resizing()
/** Pass to a resize handle's `onDraggingChange` when its drag moves a panel that can hold a native view. */
export const setPanelResizing = (dragging: boolean) => setResizing(dragging)
export const setPanelResizing = (dragging: boolean) => setResizing(dragging && !/Mac/.test(navigator.platform))
// The left sidebar and the side panel share one spring, so they move as one system. Each panel's flight takes its time
// scaled by the square root of how far it travels against a 480px panel, between 0.15s and 0.3s, so a narrow sidebar