[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(autocomplete): display placeholder only when user input is empty (#442)

authored by

James Garbutt and committed by
GitHub
(Jan 25, 2026, 10:08 PM UTC) 55eb280e c4feafb5

+55 -2
+5
.changeset/brown-banks-play.md
··· 1 + --- 2 + "@clack/prompts": patch 3 + --- 4 + 5 + Fix placeholder rendering when using autocomplete.
+1 -2
packages/prompts/src/autocomplete.ts
··· 98 98 // Title and message display 99 99 const headings = [`${color.gray(S_BAR)}`, `${symbol(this.state)} ${opts.message}`]; 100 100 const userInput = this.userInput; 101 - const valueAsString = String(this.value ?? ''); 102 101 const options = this.options; 103 102 const placeholder = opts.placeholder; 104 - const showPlaceholder = valueAsString === '' && placeholder !== undefined; 103 + const showPlaceholder = userInput === '' && placeholder !== undefined; 105 104 106 105 // Handle different states 107 106 switch (this.state) {
+33
packages/prompts/test/__snapshots__/autocomplete.test.ts.snap
··· 46 46 ] 47 47 `; 48 48 49 + exports[`autocomplete > placeholder is shown if set 1`] = ` 50 + [ 51 + "<cursor.hide>", 52 + "│ 53 + ◆ Select a fruit 54 + │ 55 + │ Search: Type to search... 56 + │ ● Apple 57 + │ ○ Banana 58 + │ ○ Cherry 59 + │ ○ Grape 60 + │ ○ Orange 61 + │ ↑/↓ to select • Enter: confirm • Type: to search 62 + └", 63 + "<cursor.backward count=999><cursor.up count=10>", 64 + "<cursor.down count=3>", 65 + "<erase.down>", 66 + "│ Search: g█ (2 matches) 67 + │ ● Grape 68 + │ ○ Orange 69 + │ ↑/↓ to select • Enter: confirm • Type: to search 70 + └", 71 + "<cursor.backward count=999><cursor.up count=7>", 72 + "<cursor.down count=1>", 73 + "<erase.down>", 74 + "◇ Select a fruit 75 + │ Grape", 76 + " 77 + ", 78 + "<cursor.show>", 79 + ] 80 + `; 81 + 49 82 exports[`autocomplete > renders bottom ellipsis when items do not fit 1`] = ` 50 83 [ 51 84 "<cursor.hide>",
+16
packages/prompts/test/autocomplete.test.ts
··· 225 225 await result; 226 226 expect(output.buffer).toMatchSnapshot(); 227 227 }); 228 + 229 + test('placeholder is shown if set', async () => { 230 + const result = autocomplete({ 231 + message: 'Select a fruit', 232 + placeholder: 'Type to search...', 233 + options: testOptions, 234 + input, 235 + output, 236 + }); 237 + 238 + input.emit('keypress', 'g', { name: 'g' }); 239 + input.emit('keypress', '', { name: 'return' }); 240 + const value = await result; 241 + expect(output.buffer).toMatchSnapshot(); 242 + expect(value).toBe('grape'); 243 + }); 228 244 }); 229 245 230 246 describe('autocompleteMultiselect', () => {