Skip to content

Commit 11a5dc1

Browse files
dreyfus92natemoo-re
authored andcommittedApr 8, 2025·
fix: add hints for selected options in multiselect prompts & tests (#279)
1 parent bc36d1c commit 11a5dc1

File tree

4 files changed

+4769
-2
lines changed

4 files changed

+4769
-2
lines changed
 

Diff for: ‎.changeset/afraid-socks-deny.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clack/prompts": patch
3+
---
4+
5+
Fixes multiselect only shows hints on the first item in the options list. Now correctly shows hints for all selected options with hint property.

Diff for: ‎packages/prompts/src/__snapshots__/index.test.ts.snap

+3,550
Large diffs are not rendered by default.

Diff for: ‎packages/prompts/src/index.test.ts

+1,208
Large diffs are not rendered by default.

Diff for: ‎packages/prompts/src/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
366366
}`;
367367
}
368368
if (state === 'selected') {
369-
return `${color.green(S_CHECKBOX_SELECTED)} ${color.dim(label)}`;
369+
return `${color.green(S_CHECKBOX_SELECTED)} ${color.dim(label)} ${
370+
option.hint ? color.dim(`(${option.hint})`) : ''
371+
}`;
370372
}
371373
if (state === 'cancelled') {
372374
return `${color.strikethrough(color.dim(label))}`;
@@ -498,7 +500,9 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
498500
}
499501
if (state === 'selected') {
500502
const selectedCheckbox = isItem || selectableGroups ? color.green(S_CHECKBOX_SELECTED) : '';
501-
return `${color.dim(prefix)}${selectedCheckbox} ${color.dim(label)}`;
503+
return `${color.dim(prefix)}${selectedCheckbox} ${color.dim(label)} ${
504+
option.hint ? color.dim(`(${option.hint})`) : ''
505+
}`;
502506
}
503507
if (state === 'cancelled') {
504508
return `${color.strikethrough(color.dim(label))}`;

0 commit comments

Comments
 (0)
Please sign in to comment.