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 @@