[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

fix: do not pass initialValue down (#328)

authored by

James Garbutt and committed by
GitHub
(May 25, 2025, 5:29 PM +0100) 8ead5d39 f90f47d8

+49 -1
+5
.changeset/sweet-deers-smell.md
··· 1 + --- 2 + "@clack/core": patch 3 + --- 4 + 5 + Avoid passing initial values to core when using auto complete prompt
+4 -1
packages/core/src/prompts/autocomplete.ts
··· 79 79 } 80 80 81 81 constructor(opts: AutocompleteOptions<T>) { 82 - super(opts); 82 + super({ 83 + ...opts, 84 + initialValue: undefined, 85 + }); 83 86 84 87 this.options = opts.options; 85 88 this.filteredOptions = [...this.options];
+25
packages/prompts/test/__snapshots__/autocomplete.test.ts.snap
··· 183 183 "<cursor.show>", 184 184 ] 185 185 `; 186 + 187 + exports[`autocomplete > supports initialValue 1`] = ` 188 + [ 189 + "<cursor.hide>", 190 + "│ 191 + ◆ Select a fruit 192 + 193 + │ Search: _ 194 + │ ○ Apple 195 + │ ○ Banana 196 + │ ● Cherry 197 + │ ○ Grape 198 + │ ○ Orange 199 + │ ↑/↓ to select • Enter: confirm • Type: to search 200 + └", 201 + "<cursor.backward count=999><cursor.up count=10>", 202 + "<cursor.down count=1>", 203 + "<erase.down>", 204 + "◇ Select a fruit 205 + │ Cherry", 206 + " 207 + ", 208 + "<cursor.show>", 209 + ] 210 + `;
+15
packages/prompts/test/autocomplete.test.ts
··· 120 120 expect(typeof value === 'symbol').toBe(true); 121 121 expect(output.buffer).toMatchSnapshot(); 122 122 }); 123 + 124 + test('supports initialValue', async () => { 125 + const result = autocomplete({ 126 + message: 'Select a fruit', 127 + options: testOptions, 128 + initialValue: 'cherry', 129 + input, 130 + output, 131 + }); 132 + 133 + input.emit('keypress', '', { name: 'return' }); 134 + const value = await result; 135 + expect(value).toBe('cherry'); 136 + expect(output.buffer).toMatchSnapshot(); 137 + }); 123 138 });