Skip to content

Drop the root :has() that restyled the app on every change - #429

Merged
broisnees merged 1 commit into
nightlyfrom
perf/webkit-style-recalc
Nov 24, 2026
Merged

broisnees merged 1 commit into
nightlyfrom
perf/webkit-style-recalc

Conversation

@broisnees

Copy link
Copy Markdown
Collaborator

On Linux, app.css hid the scrollbars behind an open dialog with html:has([role="dialog"][data-state="open"]). A root :has() makes WebKitGTK re-check it against the whole document on every DOM change, so typing, grid scrolling and streamed rows all paid that cost.

  • src/lib/dialog-open.js sets data-dialog-open on <html> while a dialog is drawn, ref-counted for nested dialogs. DialogContent and ConnectionModal drive it from their content element's ref, which bits-ui clears on close. A mounted but closed dialog doesn't hold it.
  • The root's text-rendering goes from optimizeLegibility to auto, which keeps WebKit on its fast text path. Kerning is set explicitly through font-kerning and font-feature-settings, so it's unchanged.
  • The :has() lint test also catches a pseudo-class after the :has() group.

Last PR in this group with #427 and #428, so it carries no release:skip and bumps the version.

Checked in the desktop app on Linux: the attribute is off at rest, on with Settings open, and off again after Escape. Design lint, both vitest suites (2011 + 20) and npm run build pass.

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 <html> 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.
@broisnees
broisnees merged commit 422a91b into nightly Nov 24, 2026
1 check passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant