Skip to content

Commit 24ffd25

Browse files
authored
feat(command): decompose Command.Dialog and fix Escape/separator bugs (#1064)
* feat(command): decompose Command.Dialog and fix Escape/separator bugs Decompose Command.Dialog into a Root/Trigger/Content compound namespace, fix Escape key not closing the dialog, fix Command.Separator not auto-hiding during filtering, and add browser tests covering all three. * fix preventCloseOnNestedPopupEscape behavior * fix test
1 parent c2d6ba0 commit 24ffd25

File tree

7 files changed

+778
-502
lines changed

7 files changed

+778
-502
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
"@ngrok/mantle": patch
3+
---
4+
5+
Decompose `Command.Dialog` into a `Root`/`Trigger`/`Content` namespace.
6+
7+
**Breaking change**: `Command.Dialog` is now a compound namespace instead of a monolithic component. Migrate existing usage:
8+
9+
```diff
10+
- <Command.Dialog open={open} onOpenChange={setOpen}>
11+
- <Command.Input placeholder="..." />
12+
- <Command.List>...</Command.List>
13+
- </Command.Dialog>
14+
+ <Command.Dialog.Root open={open} onOpenChange={setOpen}>
15+
+ <Command.Dialog.Content>
16+
+ <Command.Input placeholder="..." />
17+
+ <Command.List>...</Command.List>
18+
+ </Command.Dialog.Content>
19+
+ </Command.Dialog.Root>
20+
```
21+
22+
The new `Command.Dialog.Trigger` sub-component allows opening the dialog from a button without managing `open` state manually:
23+
24+
```tsx
25+
<Command.Dialog.Root>
26+
<Command.Dialog.Trigger asChild>
27+
<Button type="button">Open Command Palette</Button>
28+
</Command.Dialog.Trigger>
29+
<Command.Dialog.Content>
30+
<Command.Input placeholder="Type a command or search..." />
31+
<Command.List>...</Command.List>
32+
</Command.Dialog.Content>
33+
</Command.Dialog.Root>
34+
```
35+
36+
Also fixes two bugs:
37+
- `Command.Dialog` now correctly closes on Escape key press.
38+
- `Command.Separator` now automatically hides when all adjacent groups are filtered out.

0 commit comments

Comments
 (0)