From cd8343849d28c584f4b03981f1ed74d8b837aa57 Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 5 Jun 2026 00:52:11 +0200 Subject: [PATCH] fix(morfo): checkbox commit events sequence pre -> post (kills 244ms check lag) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The REAL cause of the slow checkbox (not the stroke duration). The checkbox provider flips its checked state inside the trigger HANDLER, and the morfo declared the commit events with sequence: 'pre' โ€” so the runtime ran `await runEmit()` BEFORE the handler. emit() awaits the visual-channel hold (~240ms), so the functional state change (and thus data-state) waited the full perceptual hold before flipping. Measured: click -> data-state='checked' took 244ms. Fix: commit-toggle-check / commit-toggle-uncheck -> sequence: 'post' (handler runs FIRST, state flips immediately, the celebratory pulse emits after). This is the doctrine for control commits (runtime.svelte.ts ยง577: "toggle's commit-toggle... the pulse arrives AFTER the state has flipped"). Toggle + Switch were already 'post'; checkbox was the outlier. Measured after: 244ms -> 46ms. Verified the siblings are NOT affected: radio-group (47ms) and tabs (31ms) are also 'pre' but flip state in the call-site (not the handler), so no lag โ€” left unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/uix/morfo/components/checkbox.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/uix/morfo/components/checkbox.ts b/src/uix/morfo/components/checkbox.ts index a133e4a2e..4f8017761 100644 --- a/src/uix/morfo/components/checkbox.ts +++ b/src/uix/morfo/components/checkbox.ts @@ -22,7 +22,10 @@ export const checkboxMorfo = { verb: 'toggle', target: v.partRef('provider'), intent: 'affirm', - sequence: 'pre' + // 'post': flip the checked state FIRST (data-state updates + // immediately), then emit the celebratory pulse. 'pre' made the + // functional check wait for the perceptual hold (~240ms) โ†’ laggy. + sequence: 'post' } }, { @@ -37,7 +40,7 @@ export const checkboxMorfo = { verb: 'toggle', target: v.partRef('provider'), intent: 'neutral', - sequence: 'pre' + sequence: 'post' } } ],