Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions apps/web/src/components/browser/BrowserHostLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ export function LiveThreadBrowserView({ browser }: { browser: LiveThreadBrowserR
left: "anchor(left)",
width: "anchor-size(width)",
height: "anchor-size(height)",
// Over the app, under toasts (z-45) and menus and dialogs (z-50).
zIndex: 40,
}
: {
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/device/DeviceFloatingWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ function FloatingDevice(props: {
aria-label={`${props.name}, floating`}
data-testid="device-float"
className={cn(
// Under toasts (z-45), which land in the same corner it first floats to.
"fixed z-40 flex flex-col rounded-xl bg-popover text-popover-foreground ring-1 ring-border elevate-overlay",
live && "select-none",
)}
Expand Down
14 changes: 12 additions & 2 deletions apps/web/src/components/ui/toast.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ import { ToastProvider, stackedThreadToast, toastManager } from "./toast";
*/
const APP_OVERLAY_LAYER = 50;

/**
* The layer of things that are part of the workspace and float over the app:
* the browser panel's live page, a device floated over the chat, the floating
* thread list. They reach the toast corner and are added to the body after
* the toast viewport, so a tie with them puts the toast underneath.
*/
const WORKSPACE_LAYER = 40;

/**
* Says whether this page has focus, for the rest of the spec. Notice clocks run
* only while the window is in front, and a spec's frame has focus only if an
Expand Down Expand Up @@ -76,8 +84,10 @@ describe("toast layering", () => {
zIndex,
`the toast viewport is at z-index ${zIndex}; anything at or above ${APP_OVERLAY_LAYER} swallows clicks meant for an open menu`,
).toBeLessThan(APP_OVERLAY_LAYER);
// Still above the page it floats over.
expect(zIndex).toBeGreaterThan(0);
expect(
zIndex,
`the toast viewport is at z-index ${zIndex}; the browser page and floating windows at ${WORKSPACE_LAYER} cover it`,
).toBeGreaterThan(WORKSPACE_LAYER);

// The card inside inherits the viewport's stacking context, so its own
// very high z-index cannot lift it out past the overlays.
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/components/ui/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,14 @@ function Toasts({ position = "top-right" }: { position: ToastPosition }) {
// top-right corner the panel's tab menu opens into, so at z-100 it
// was swallowing clicks meant for a menu the user had just opened.
// Ambient notice yields to whatever the user is actually doing.
// Above the layers that are part of the workspace, all at z-40 and
// all able to reach this corner: the browser panel's live page, a
// device floated over the chat, the floating thread list. A tie
// would go to whichever was added to the body last, and the browser
// page and the device float both arrive after this viewport.
// A dimmed backdrop is the exception: the user is in a dialog, and
// a notice raised then must not sit blurred underneath it.
raisedAboveBackdrops ? "z-60" : "z-40",
raisedAboveBackdrops ? "z-60" : "z-45",
"fixed mx-auto flex w-[calc(100%-var(--toast-inset)*2)] max-w-[20rem] [--toast-header-offset:52px] [--toast-inset:--spacing(4)] sm:[--toast-inset:--spacing(6)]",
// Vertical positioning
"data-[position*=top]:top-[calc(var(--toast-inset)+var(--toast-header-offset))]",
Expand Down
Loading