ReviewOS

stacks/stx

Preserve caller event handlers in plain-script component slots

#2126
Closed chris opened this 6 days ago ·
6 days ago

A caller's event handlers fail inside a slot-taking component that has a plain client script. The production case is the maintained DialogPanel: it declares the platform systemSheet value, while the caller provides two confirmation buttons and their functions. With no caller mustache expression in the panel slot, clicking a button throws ReferenceError: cancelDemolition is not defined and leaves the dialog open.

A standalone Chrome regression using the maintained Dialog, DialogPanel, DialogBackdrop and DialogTitle reproduces the failure. The page owns shown, answer, cancel() and confirm(); its panel slot has only static text and event-bound buttons. Opening succeeds, but cancellation fails. Adding unrelated text expressions is not a solution.

The component compiler selects static event extraction from the component's own script alone. That moves caller-authored slot handlers into the component's local script instead of retaining reactive scope lookup. Related game issue: stacksjs/the-settlers-iii-remake#226.

Acceptance:

  • Keep caller event handlers on the maintained reactive scope path when a plain-script component receives reactive caller slot events.
  • Preserve the component's own client bindings and ordinary static component behavior.
  • Retain a real Chrome regression covering both cancellation and confirmation, safe focus and opener restoration.
  • Pass relevant compiler/component regressions, lint, types, full source tests and normal patch release gates.
  • Verify original published packages and adopt them through Stacks before game acceptance.
2 days ago

Fixed by dc47421 (retain caller handlers in plain-script component slots), released in v0.2.720, with the static-build regression in 007bf83. The Settlers III remake's demolition dialog (the production case here) cancels and confirms correctly on 0.2.754 in its browser gate.

6 days ago

The compiler correction and Chrome regression are now on main. Plain-script panels receiving reactive caller slot events retain the maintained scope path, so cancellation and confirmation can call the owning page functions and restore focus.

Local validation: 17,246 passing tests, 34 existing skips, no failures; lint and types; the normal release preflight, including actual archive installation, export validation, performance budgets and 324 focused tests. Current upstream Image changes were integrated, and the combined dialog, slot and Image regressions plus release preflight also pass.

The normal 0.2.720 patch release is running. This issue remains open until the original publications are verified and adopted through Stacks into the game's production browser checks.

5 days ago

Published-package audit: the upstream fix (dc47421) is present and verified in STX/components 0.2.736. Fresh unmodified npm installs pass the maintained packages/components/test/dialog-caller-events-browser.test.ts scenarios in real Chrome, including caller cancellation/confirmation handlers, repeated openings and restored opener focus. Source dialog/ref/library regressions: 38 passed, 0 failed; complete installed-package/sample audit: 12 passed, 0 failed, Bun 1.4.2. Original npm archives were SHA1/SHA512 verified, and all installed files match them. Latest main CI is green: https://github.com/stacksjs/stx/actions/runs/40673334028 .

Leaving this issue open for its explicit downstream adoption/acceptance requirement. The game's current committed package.json at 9d2c6f5 still pins STX/components/bun-plugin-stx 0.2.719; its latest successful game CI is not evidence for these newer compiler fixes. The earlier local adoption report in stacksjs/the-settlers-iii-remake#226 has not yet been followed by final downstream acceptance evidence. Next gate: the game owner adopts qualified packages through Stacks and reruns its full production browser check, including invalid-seed focus. No downstream dependencies or Craft code changed in this audit.

Sign in to comment on this issue.