Fixed overlay windows rendering below other UI

This commit is contained in:
patben8 committed 2026-09-25 15:23:16 +02:00
1 parent 2810f24563
commit be80e572e5
16 files changed
+99 -60

No files matched your search

+11
View File
@@ -675,6 +675,17 @@ easy to break:
placed relative to the panel, not the window — the sidebar's playlist menu
opened far from the cursor. `.glass`'s blur and tint therefore live on its
`::after` (z-index -1 under `isolation: isolate`), not on the panel.
- **Every overlay renders through `createPortal(…, document.body)`** — all
dialogs, `ContextMenu` and `Toast`. Each `.glass` panel is a stacking context
(`isolation`), so an overlay rendered INSIDE one can never rise above a
neighbouring panel, whatever its z-index: New Export (from the sidebar) sat
behind the library, and the deck's Auto Hotcues dialog behind both. One
z scale, set on the overlay's root: dialogs `z-50`, a dialog opened from a
dialog (`FolderPicker`) `z-[60]`, menus `z-[70]`, toasts `z-[80]`. A new
overlay that skips the portal will look fine when opened from `App` and break
the first time a panel opens it. Small popovers anchored to a control inside a
scrolling list should open the shared `ContextMenu` instead (as the playlist
row's "Add to export" does) — a popover inside the list is clipped by it.
- **The accent is `oklch(0.8 0.11 var(--accent-hue))`** — the cover's hue at a
FIXED lightness and chroma, so dark text on it keeps its contrast whatever is
loaded. `lib/ambient.ts` sets `--accent-hue` and `--amb-1..4` on `<html>`;
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useEffect } from 'react'
interface Props {
@@ -23,10 +24,10 @@ export function AnalyzeGridDialog({ total, existing, locked, onChoose, onClose }
return () => window.removeEventListener('keydown', onKey)
}, [onClose])
return (
return createPortal(
<div
aria-modal="true"
className="fixed inset-0 z-40 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
onClick={onClose}
>
<div
@@ -78,6 +79,7 @@ export function AnalyzeGridDialog({ total, existing, locked, onChoose, onClose }
)}
</div>
</div>
</div>
</div>,
document.body,
)
}
+5 -3
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useEffect, useState } from 'react'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import {
@@ -151,8 +152,8 @@ export function AutoCueDialog(props: Props) {
}
}
return (
<div aria-modal="true" className="fixed inset-0 z-40 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6" onClick={() => !busy && onClose()}>
return createPortal(
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6" onClick={() => !busy && onClose()}>
<div
className="flex max-h-[85vh] w-full max-w-xl flex-col overflow-hidden glass-overlay"
onClick={(e) => e.stopPropagation()}
@@ -293,6 +294,7 @@ export function AutoCueDialog(props: Props) {
</button>
</div>
</div>
</div>
</div>,
document.body,
)
}
+5 -3
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useEffect, useState, type ReactNode } from 'react'
export interface ConfirmRequest {
@@ -43,10 +44,10 @@ export function ConfirmDialog({ title, body, confirmLabel, onConfirm, onClose }:
return () => window.removeEventListener('keydown', onKey)
})
return (
return createPortal(
<div
aria-modal="true"
className="fixed inset-0 z-40 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
onClick={() => !busy && onClose()}
>
<div
@@ -74,6 +75,7 @@ export function ConfirmDialog({ title, body, confirmLabel, onConfirm, onClose }:
</button>
</div>
</div>
</div>
</div>,
document.body,
)
}
+5 -3
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import type { ReactNode } from 'react'
import { useEffect, useRef, useState } from 'react'
import { Icon } from '../lib/icons'
@@ -55,7 +56,7 @@ export function ContextMenu({ x, y, items, onClose }: Props) {
}
}, [])
return (
return createPortal(
// `contents`: the panels are fixed-positioned, so this wrapper must take no
// part in layout. As an ordinary empty block it became one more item in
// the app's gapped flex column and pushed every panel down by a gap.
@@ -69,7 +70,8 @@ export function ContextMenu({ x, y, items, onClose }: Props) {
return { top, left: Math.min(x, window.innerWidth - 180), maxHeight: window.innerHeight - top - 8 }
})()}
/>
</div>
</div>,
document.body,
)
}
@@ -101,7 +103,7 @@ function MenuPanel({
return (
<>
<div
className={`glass-overlay fixed z-50 overflow-y-auto rounded-2xl p-1.5 ${className}`}
className={`glass-overlay fixed z-[70] overflow-y-auto rounded-2xl p-1.5 ${className}`}
style={style}
>
{items.map((item, i) => {
+5 -3
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useRef, useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type Track } from '../api'
@@ -95,9 +96,9 @@ export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
apply.mutate()
}
return (
return createPortal(
<div
aria-modal="true" className="fixed inset-0 z-40 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
onClick={onClose}
>
<div
@@ -247,6 +248,7 @@ export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
</button>
</div>
</div>
</div>
</div>,
document.body,
)
}
+4 -2
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useState } from 'react'
import { useQuery } from '@tanstack/react-query'
import { api, type ExportSet } from '../api'
@@ -58,7 +59,7 @@ export function ExportDialog({ editing, onClose, onSaved, onError }: Props) {
}
}
return (
return createPortal(
<>
{browsing && (
<FolderPicker
@@ -165,6 +166,7 @@ export function ExportDialog({ editing, onClose, onSaved, onError }: Props) {
</div>
</div>
</div>
</>
</>,
document.body,
)
}
+4 -2
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useEffect, useRef, useState } from 'react'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type ExportPreview, type ExportSet, type JobStatus } from '../api'
@@ -100,7 +101,7 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
const pct = job && job.total > 0 ? Math.min(100, (job.done / job.total) * 100) : null
const blocked = p?.blocked ?? null
return (
return createPortal(
<div aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
<div className="w-full max-w-lg glass-overlay">
<div className="border-b border-line px-5 py-3">
@@ -260,6 +261,7 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
)}
</div>
</div>
</div>
</div>,
document.body,
)
}
+4 -2
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useState } from 'react'
import { FileBrowser, useFsListing } from './FileBrowser'
@@ -30,7 +31,7 @@ export function FolderPicker({ value, onChange, onClose }: Props) {
onClose()
}
return (
return createPortal(
<div aria-modal="true" className="fixed inset-0 z-[60] flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-4">
<div className="flex h-[70vh] w-full max-w-2xl flex-col overflow-hidden glass-overlay">
<div className="border-b border-line px-5 py-3">
@@ -80,6 +81,7 @@ export function FolderPicker({ value, onChange, onClose }: Props) {
</button>
</div>
</div>
</div>
</div>,
document.body,
)
}
+5 -3
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type HistoryEntry } from '../api'
@@ -78,9 +79,9 @@ export function HistoryPanel({ onClose, onNotify, onError }: Props) {
const entries = history.data ?? []
return (
return createPortal(
<div
aria-modal="true" className="fixed inset-0 z-40 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
onClick={onClose}
>
<div
@@ -207,6 +208,7 @@ export function HistoryPanel({ onClose, onNotify, onError }: Props) {
)}
</div>
</div>
</div>
</div>,
document.body,
)
}
+4 -2
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useEffect, useRef, useState } from 'react'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type ImportPreview, type JobStatus } from '../api'
@@ -141,7 +142,7 @@ export function ImportDialog({ playlistId, deviceLabel, onClose, onDone, onError
const finished = job != null && job.state !== 'running'
const pct = job && job.total > 0 ? Math.min(100, (job.done / job.total) * 100) : null
return (
return createPortal(
<>
{browsing && (
<FolderPicker
@@ -322,6 +323,7 @@ export function ImportDialog({ playlistId, deviceLabel, onClose, onDone, onError
</div>
</div>
</div>
</>
</>,
document.body,
)
}
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useEffect, useRef, useState } from 'react'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { api, type RemapPreview } from '../api'
@@ -102,9 +103,9 @@ export function PathMappingDialog({ onClose, onNotify, onError }: Props) {
const canCommit = !!from.trim() && !!to.trim()
return (
return createPortal(
<div
aria-modal="true" className="fixed inset-0 z-40 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
onClick={onClose}
>
<div
@@ -246,7 +247,8 @@ export function PathMappingDialog({ onClose, onNotify, onError }: Props) {
</button>
</div>
</div>
</div>
</div>,
document.body,
)
}
+5 -3
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useEffect } from 'react'
import { useCaps } from '../lib/capabilities'
@@ -94,10 +95,10 @@ export function ShortcutsDialog({ onClose }: Props) {
return () => window.removeEventListener('keydown', onKey)
}, [onClose])
return (
return createPortal(
<div
aria-modal="true"
className="fixed inset-0 z-40 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
onClick={onClose}
>
<div
@@ -136,6 +137,7 @@ export function ShortcutsDialog({ onClose }: Props) {
))}
</div>
</div>
</div>
</div>,
document.body,
)
}
+23 -23
View File
@@ -92,6 +92,8 @@ interface RowActions {
onRename: (node: PlaylistNode, name: string) => void
onDelete: (node: PlaylistNode) => void
onAddToExport: (node: PlaylistNode, setId: string) => void
/** The row's export button: the export list as a menu under it. */
onPickExport: (e: React.MouseEvent<HTMLElement>, node: PlaylistNode) => void
onCommitDraft: (name: string) => void
onCancelDraft: () => void
}
@@ -165,7 +167,6 @@ function NodeRow({
actions: RowActions
}) {
const [open, setOpen] = useState(true)
const [adding, setAdding] = useState(false)
const renaming = renamingId === node.id
const [renameDraft, setRenameDraft] = useState(node.name)
const isFolder = node.kind === 'folder'
@@ -245,32 +246,13 @@ function NodeRow({
library being writable: an export set is Konduktor's own curation
and adding to one changes nothing in the user's library. */}
{!renaming && exportSets.length > 0 && (
<div className="relative shrink-0">
<button
title="Add to an export"
onClick={() => setAdding((a) => !a)}
className="hidden rounded px-1 text-faint hover:text-gold group-hover:block"
onClick={(e) => actions.onPickExport(e, node)}
className="hidden shrink-0 rounded px-1 text-faint hover:text-gold group-hover:block"
>
<Icon name="export" size={13} />
</button>
{adding && (
<div className="glass-overlay absolute right-0 top-full z-30 mt-1 w-48 !rounded-2xl p-1.5">
{exportSets.map((set) => (
<button
key={set.id}
onClick={() => {
setAdding(false)
actions.onAddToExport(node, set.id)
}}
className="flex w-full items-center gap-2 rounded-[10px] px-2 py-1.5 text-left text-sm text-muted hover:bg-ink-800 hover:text-text"
>
<span className="shrink-0 text-gold"><Icon name="export" size={13} /></span>
<span className="truncate">{set.name}</span>
</button>
))}
</div>
)}
</div>
)}
{!renaming && node.can_rename && (
<button
@@ -486,6 +468,24 @@ export function Sidebar({
onRename: (node, name) => rename.mutate({ node, name }),
onDelete: confirmDelete,
onAddToExport: (node, setId) => addToExport.mutate({ node, setId }),
// Opened as the shared ContextMenu rather than a popover inside the row: the
// playlist list scrolls, and a popover inside it was clipped by its edges.
onPickExport: (e, node) => {
e.stopPropagation()
const r = e.currentTarget.getBoundingClientRect()
setMenu({
x: r.left,
y: r.bottom + 4,
items: [
{ heading: 'Add to export' },
...exportSets.map((set) => ({
label: set.name,
icon: <Icon name="export" size={13} />,
onClick: () => addToExport.mutate({ node, setId: set.id }),
})),
],
})
},
onCommitDraft: (name) => {
if (draft) create.mutate({ ...draft, name })
setDraft(null)
@@ -494,7 +494,7 @@ export function Sidebar({
}
return (
<aside className="glass flex h-full w-64 shrink-0 flex-col overflow-hidden">
<aside className="glass flex h-full w-64 shrink-0 flex-col">
{/* Which library is open — and the way to open a different one. Until
this existed the picker was a one-way door: it ran once at startup and
nothing could summon it again, so changing library meant restarting.
+5 -3
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useEffect } from 'react'
export interface ToastMsg {
@@ -20,8 +21,8 @@ export function Toast({ toast, onClose }: { toast: ToastMsg | null; onClose: ()
}, [toast, onClose])
if (!toast) return null
return (
<div className="pointer-events-none fixed inset-x-0 top-4 z-50 flex justify-center">
return createPortal(
<div className="pointer-events-none fixed inset-x-0 top-4 z-[80] flex justify-center">
<div
className="glass-overlay pointer-events-auto flex max-w-lg items-center gap-3 !rounded-full px-5 py-2.5 text-sm text-text"
>
@@ -29,6 +30,7 @@ export function Toast({ toast, onClose }: { toast: ToastMsg | null; onClose: ()
<span className={`h-2 w-2 shrink-0 rounded-full ${KIND_CLS[toast.kind]}`} />
{toast.text}
</div>
</div>
</div>,
document.body,
)
}
+4 -2
View File
@@ -1,3 +1,4 @@
import { createPortal } from 'react-dom'
import { useState } from 'react'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { api } from '../api'
@@ -146,7 +147,7 @@ export function UpdateCheck() {
const changes = whatsChanged(latest.body)
return (
return createPortal(
<div
aria-modal="true" className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[3px] p-6"
onClick={close}
@@ -206,6 +207,7 @@ export function UpdateCheck() {
</button>
</div>
</div>
</div>
</div>,
document.body,
)
}