From a60abef4bf02a6d3847d8d7a8ab780d362342d67 Mon Sep 17 00:00:00 2001 From: dev Date: Mon, 22 Jun 2026 19:04:24 +0200 Subject: [PATCH] feat(command): Command.Dialog closes on item select MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Selecting an item ran its onSelect but nothing closed the dialog. Add a provider-level `onSelect` to the soma command (fires for ANY item, on BOTH paths — `selectCurrent` for the keyboard + the item `onclick` for the mouse, after the item's own onSelect). The eidos `` hooks it → `open = false`. Verified in-browser: click → closes; Enter → closes. check 0; command provider tests 2/2. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../components/command/command-dialog.svelte | 1 + .../components/command/command-provider.svelte.ts | 15 ++++++++++++++- .../components/command/components/command.svelte | 9 ++++----- src/uix/soma/components/command/types.ts | 15 +++++++++------ 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/uix/eidos/components/command/command-dialog.svelte b/src/uix/eidos/components/command/command-dialog.svelte index e2da9050f..200383383 100644 --- a/src/uix/eidos/components/command/command-dialog.svelte +++ b/src/uix/eidos/components/command/command-dialog.svelte @@ -65,6 +65,7 @@ (open = false)} bind:value onValueChange={(v) => onValueChange?.(v)} bind:search diff --git a/src/uix/soma/components/command/command-provider.svelte.ts b/src/uix/soma/components/command/command-provider.svelte.ts index 479e2d3df..84c6bb99c 100644 --- a/src/uix/soma/components/command/command-provider.svelte.ts +++ b/src/uix/soma/components/command/command-provider.svelte.ts @@ -86,7 +86,11 @@ interface CommandOpts columns: number; disablePointerSelection: boolean; dir: 'ltr' | 'rtl'; - }> {} + }> { + /** Provider-level select event — fires for ANY item (after its own + * onSelect). A host (Command.Dialog) hooks it to close on select. */ + onSelect?: Active<((value: string) => void) | undefined>; +} export class CommandProvider { readonly opts: CommandOpts; @@ -380,6 +384,9 @@ export class CommandProvider { const entry = this.findItem(value); if (!entry || entry.disabled || !this.isVisible(value)) return; this.onSelectHandlers.get(value)?.(value); + // Provider-level select event — fires for ANY item, after its own onSelect. + // A host (Command.Dialog) hooks it to close on select. + this.opts.onSelect?.current?.(value); // Morfo: commit-submit-invoke on `item`. Look up the item element // by data-value so the cascade matches this specific item (Enter // key path — onclick handler emits independently for mouse path). @@ -708,6 +715,9 @@ export class CommandItemProvider { if (this.opts.disabled.current) return; this.provider.setValue(this.opts.value.current); this.opts.onSelect.current?.(this.opts.value.current); + // Provider-level select event (mouse path) — mirrors selectCurrent's fire + // on the keyboard path, so a host (Command.Dialog) closes on click too. + this.provider.opts.onSelect?.current?.(this.opts.value.current); // Morfo: commit-submit-invoke on `item` (affirm). Fire with the // clicked element so the cascade matches this specific item. void this.provider.runtime.trigger('commit-submit-invoke', { @@ -834,6 +844,9 @@ export class CommandLinkItemProvider { return; } this.opts.onSelect.current?.(this.opts.value.current); + // Provider-level select event (mouse path) — so a host (Command.Dialog) + // closes on a link-item click too. + this.provider.opts.onSelect?.current?.(this.opts.value.current); }; readonly onpointermove = () => { diff --git a/src/uix/soma/components/command/components/command.svelte b/src/uix/soma/components/command/components/command.svelte index 62dbb6181..a82934a13 100644 --- a/src/uix/soma/components/command/components/command.svelte +++ b/src/uix/soma/components/command/components/command.svelte @@ -1,8 +1,5 @@