From ed045b918cdba23535aab3030b46993cb7c6e7cd Mon Sep 17 00:00:00 2001 From: broisnees Date: Tue, 24 Nov 2026 12:14:30 +0000 Subject: [PATCH] Drop the root :has() that restyled the app on every change app.css hid the scrollbars behind an open dialog on Linux with html:has([role="dialog"][data-state="open"]). A :has() on the root makes WebKitGTK re-check it against the whole document on every DOM change anywhere, so typing, scrolling the grid or streaming rows all paid for it. dialog-open.js sets data-dialog-open on while a dialog is drawn, ref-counted for nested dialogs. DialogContent and ConnectionModal set it from their content element's ref, which bits-ui clears on close, so a dialog that is mounted but closed does not hold it. The rule keys on the attribute instead. The root's text-rendering goes from optimizeLegibility to auto, which keeps WebKit on its fast text path. font-kerning and the kern/calt features are set explicitly, so kerning does not change. The non-subject :has() lint now also catches a pseudo-class after the :has() group. --- .changeset/webkit-style-recalc.md | 3 ++ src/app.css | 18 +++++------- src/lib/components/ConnectionModal.svelte | 10 +++++++ .../ui/dialog/dialog-content.svelte | 10 +++++++ src/lib/dialog-open.js | 26 +++++++++++++++++ src/lib/dialog-open.test.js | 29 +++++++++++++++++++ src/lib/webkit-has-selectors.test.js | 2 +- 7 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 .changeset/webkit-style-recalc.md create mode 100644 src/lib/dialog-open.js create mode 100644 src/lib/dialog-open.test.js diff --git a/.changeset/webkit-style-recalc.md b/.changeset/webkit-style-recalc.md new file mode 100644 index 00000000..20a104c6 --- /dev/null +++ b/.changeset/webkit-style-recalc.md @@ -0,0 +1,3 @@ +### Changes + +- **Less style work on every change** - Linux no longer re-checks a whole-document selector on every DOM change to hide scrollbars behind an open dialog; an attribute on the window root does it instead. Text uses the browser's default rendering mode, which keeps WebKit's fast text path while kerning stays on. diff --git a/src/app.css b/src/app.css index 72a5e2c9..18a1afea 100644 --- a/src/app.css +++ b/src/app.css @@ -528,12 +528,9 @@ html[data-os="linux"] { --window-radius: 8px; } grayscale strokes can pick Grayscale in Settings -> Appearance. */ -webkit-font-smoothing: auto; -moz-osx-font-smoothing: auto; - /* optimizeLegibility: proper kerning + shaping so UI text stays smooth and - crisp at every zoom level (optimizeSpeed skips shaping and looks rough, - especially scaled down). The perf-sensitive data grid opts back into - optimizeSpeed via a scoped rule (.studio-data-table) so large grids don't - pay the shaping cost on every cell. */ - text-rendering: optimizeLegibility; + /* auto: lets WebKit/Blink use the fast ASCII text path while font-kerning + and font-feature-settings below still apply kerning cleanly. */ + text-rendering: auto; /* font-synthesis and text-size-adjust omitted: font-synthesis:none can trigger a WebKit font assertion on Linux startup; text-size-adjust is a no-op on desktop. */ } @@ -1819,13 +1816,14 @@ html:not(.dark) .key-well:focus-within { box-shadow: inset 0 0 0 1px var(--ring) /* Linux (WebKitGTK) can draw a scroll area's scrollbar on its own layer, above everything, so the sidebar's bar showed through Settings and other dialogs. - While a dialog is open, the scrollbars behind it are hidden; the dialog's - own keep working. */ -html[data-os="linux"]:has([role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]) + Driven by `html[data-dialog-open]` (set while a DialogContent is drawn) + instead of a root `:has()` selector, which made WebKitGTK invalidate styles + across the entire DOM on every unrelated mutation. */ +html[data-os="linux"][data-dialog-open] :is(.app-scroll, .overflow-auto, .overflow-y-auto, .overflow-x-auto):not(:is([role="dialog"], [role="alertdialog"]) *) { scrollbar-width: none; } -html[data-os="linux"]:has([role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]) +html[data-os="linux"][data-dialog-open] :is(.app-scroll, .overflow-auto, .overflow-y-auto, .overflow-x-auto):not(:is([role="dialog"], [role="alertdialog"]) *)::-webkit-scrollbar { display: none; } diff --git a/src/lib/components/ConnectionModal.svelte b/src/lib/components/ConnectionModal.svelte index b04a4f27..e086b256 100644 --- a/src/lib/components/ConnectionModal.svelte +++ b/src/lib/components/ConnectionModal.svelte @@ -93,6 +93,7 @@ import { ScrollArea } from "$lib/components/ui/scroll-area/index.js"; import { Button } from "$lib/components/ui/button/index.js"; import { Dialog as DialogPrimitive } from "bits-ui"; + import { beginDialogOpen, endDialogOpen } from "$lib/dialog-open.js"; import ResizeHandle from "./ResizeHandle.svelte"; import { cn } from "$lib/utils.js"; import { IS_MAC, comboTitle } from '$lib/shortcuts.js'; @@ -3416,6 +3417,14 @@ /* browser/non-Tauri env */ } } + // Same open-dialog marker as ui/dialog's DialogContent: set while the + // dialog element is drawn, so app.css can hide the scrollbars behind it. + let dialogContentEl = $state(/** @type {HTMLElement | null} */ (null)); + $effect(() => { + if (!dialogContentEl) return; + beginDialogOpen(); + return () => endDialogOpen(); + }); /g, '') .replace(/\/\*[\s\S]*?\*\//g, '') .replace(/^\s*\/\/.*$/gm, '') - for (const re of [/\bgroup-has-[\w[\]>=-]*\//g, /\bhas-\[[^\]\s]*\]\]?:\[&/g, /:has\([^)]*\)\s+[[.\w*]/g]) { + for (const re of [/\bgroup-has-[\w[\]>=-]*\//g, /\bhas-\[[^\]\s]*\]\]?:\[&/g, /:has\([^)]*\)\s+[[.\w*:]/g]) { for (const m of src.matchAll(re)) bad.push(`${path.relative(root, f)}: ${m[0]}`) } }