Skip to content

fix(ui): keep overlays and CAccordion working with children-first onServerRender - #675

Merged
JuroOravec merged 1 commit into
mainfrom
fix/651-overlay-rerender
Nov 14, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
fix/651-overlay-rerender

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Since #651, Citry runs onServerRender callbacks after a server render with children before their parent, after every cleanup has run. This order is documented and stays. Several Citry UI components were written for the parent-first order, and 21 cases in the e2e job have failed on main since then. This PR fixes the components, not the tests.

What went wrong, and the fix

  • CDatePicker, CDateRange, CTimePicker. The picker's cleanup removed data-enhanced, which hid the trigger of its child CPopover. The popover's callback now runs first, so it saw a hidden trigger and force-closed with reason "ancestor". That also explains the 'ancestor' instead of 'disabled' in the disable test. The picker's cleanup now accepts {handoff: true} and keeps the control enhanced on a server render. A small *AwaitingRun flag keeps the popup closed between the cleanup and the picker's own run when the server has just disabled the picker, so the popup does not flash open and then close.
  • CPopover inside an open CPopover. The outer popover's cleanup hid its surface, so the inner one's earlier callback closed. An open popover now stays showing and registered across the handoff, and its next run takes the layer over without replaying the entry animation or moving focus.
  • CAccordion. Items register in their own callbacks, so they are now registered before the accordion runs. Its first effects then normalized the value against the new items before reconcileStructure could see which items were removed, and it skipped the removal report and the focus fallback. It now applies no item state until it has reconciled, and it reconciles right away when items are already registered.
  • CDialog, CDrawer, CCommandPalette nested in a dialog. When one render opened both levels, the inner callback ran while the outer dialog was open only because of its server-rendered open attribute. The inner one then entered the top layer first, or the outer CDrawer refused to open. The inner one now waits, one task at a time, until the enclosing dialog is modal, with a counter that cancels a stale retry. Separately, CDrawer watched only its host's attributes, because a second observe() call on a node replaced the first call's options. It now watches every ancestor. The palette also joins the shared dialog list while it is open, so a closing CDrawer closes it.

Checked

  • I bisected the regression to the callback order alone: rebuilding the runtime with the old order made all 21 cases pass.
  • Locally, against the published citry-core==1.9.1:
    • the citry_ui e2e suite: 1085 passed, 17 xfailed. Not run: the two Tailwind CSS coexistence files and the type-check test, which need generated CSS and citry-lsp;
    • the non-e2e citry_ui tests pass;
    • ruff passes.
  • New regression tests:
    • a CPopover nested in a CPopover across a server render;
    • CCommandPalette as the innermost level inside CDialog and CDrawer;
    • for every nested case, a check that the innermost overlay is on top.
  • Asset budgets. The added code takes the catalog past its JavaScript budget, which had only 1.1 KiB of gzip headroom. I raised the catalog JavaScript limits by 8 KiB gzip and 4 KiB brotli, and the CCommandPalette family limits by about 1 KiB. The reasons are written beside the limits. Please confirm you are fine with that.

Not in this PR

  • A popup opened inside a dialog in the same render. When one server render opens a CDialog and also renders a CPopover, CSelect, CMenu, or another popup inside it open, the popup ends up closed. This fails with the old callback order too, so feat(vue): guarantee script order and failure behaviour (#145) #651 did not cause it.
  • Possible siblings from a code-reading sweep, not reproduced:
    • CSortable re-appends every item on each run, which could hide an open popup inside an item;
    • a grouped CToggle reads its group's data-disabled before the group runs;
    • CFileInput inside CField gets the wrong readonly capability. This one does not depend on the order.
  • One shared helper. enclosingDialogWait exists both in the dialog controller and in CDrawer.

Security: this changes only component browser code (overlay open state, top-layer order, layer registration, timers). No value from data reaches a new place in the page. An independent reviewer confirmed this and checked the advisory survey's DOM-clobbering, prototype, hydration and denial-of-service kinds.

🤖 Generated with Claude Code

…erverRender

Since #651, Citry runs onServerRender callbacks after a server render with
children before their parent, after every cleanup has run. Several Citry UI
components relied on the parent's callback running first:

- CDatePicker, CDateRange and CTimePicker un-enhanced their control in the
  cleanup, which hid the trigger of their CPopover, so the popover's earlier
  callback force-closed it. Their cleanup now keeps the control enhanced on a
  server-render handoff, and the popup stays closed while the server has just
  disabled the picker and the picker has not run yet.
- An open CPopover hid its surface in the cleanup, so a layer nested inside it
  closed. It now stays showing and registered until its next run takes it over.
- CAccordion applied item state before detecting removed items, so it skipped
  the removal report and the focus fallback. It reconciles the items first.
- A CDialog, CDrawer or CCommandPalette opened inside a dialog that the same
  render opens now waits until that dialog is modal, so it opens on top. CDrawer
  watches every ancestor's attributes, and the palette joins the shared dialog
  list, so closing the outer one closes them.

The JavaScript asset budgets rise to fit the added code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec force-pushed the fix/651-overlay-rerender branch from e6db264 to 698fbe6 Compare November 14, 2026 19:40
@JuroOravec
JuroOravec merged commit 499f4fc into main Nov 14, 2026
25 of 29 checks passed
@JuroOravec
JuroOravec deleted the fix/651-overlay-rerender branch November 14, 2026 20:12
JuroOravec added a commit that referenced this pull request Nov 14, 2026
…ight merged changes (#682)

Add one record under docs/security/reviews/ for each of the eight published
0.8.0 advisories (GHSA-4hj5, -8xvf, -7qpw, -g658, -x6rm, -h524, -xmx5,
-xg8c) and for each of the pull requests that Mechanism 7, step 7 owes one:
#610, #640, #651, #652, #653, #658, #674 and #675. Each record says only what
the public pull request, the published advisory, the merged code and its tests
show, and lists what was not checked.

The reviews README describes how a record for a published advisory differs
from a pull request record. The Mechanism 7 list in CLAUDE.md gains the two
places that GHSA-7qpw added: parser rules browsers differ on, and the page's
declared encoding.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant