diff --git a/packages/app/component-tests/browser-pane.spec.ts b/packages/app/component-tests/browser-pane.spec.ts index e574bc7af91..e676d0f5ae4 100644 --- a/packages/app/component-tests/browser-pane.spec.ts +++ b/packages/app/component-tests/browser-pane.spec.ts @@ -42,3 +42,18 @@ story("hides and restores the same registration for Review tabs and unmount", as await root.getByRole("button", { name: "Unmount pane", exact: true }).click() await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "false") }) + +story("hides the native view immediately while the pane stays mounted", async ({ page }) => { + const root = page.getByTestId("browser-pane-fixture") + const toggle = root.getByRole("button", { name: "Toggle Review tab", exact: true }) + await expect(toggle).toBeEnabled() + // Read in the same task as the click so a deferred animation-frame hide cannot pass. + const visible = await toggle.evaluate((element) => { + element.dispatchEvent(new MouseEvent("click", { bubbles: true })) + return document.querySelector('[data-testid="native-Alpha"]')?.getAttribute("data-visible") + }) + expect(visible).toBe("false") + await expect(root.locator("#browser-panel")).toHaveCount(1) + await toggle.click() + await expect(root.getByTestId("native-Alpha")).toHaveAttribute("data-visible", "true") +}) diff --git a/packages/app/src/session/browser/pane.tsx b/packages/app/src/session/browser/pane.tsx index fd16dfca801..77a621a9b9f 100644 --- a/packages/app/src/session/browser/pane.tsx +++ b/packages/app/src/session/browser/pane.tsx @@ -127,6 +127,12 @@ export function SessionBrowserPane(props: { browser: ReturnType { layout = undefined + // Native views are not clipped by the retained panel's DOM. Hide before + // the next animation frame so closing the panel cannot leave its page above the app. + if (!props.visible || !store.visible || dialog.active || !state()) { + registration()?.setLayout() + return + } schedule(300) }, ), diff --git a/packages/app/src/session/files/session-side-panel.tsx b/packages/app/src/session/files/session-side-panel.tsx index ee2723007ed..a48ace00b86 100644 --- a/packages/app/src/session/files/session-side-panel.tsx +++ b/packages/app/src/session/files/session-side-panel.tsx @@ -595,7 +595,10 @@ export function SessionSidePanel(props: { classList={{ hidden: !isSessionBrowserTab(activeTab()) }} inert={!isSessionBrowserTab(activeTab()) || undefined} > - +