prompts icon indicating copy to clipboard operation
prompts copied to clipboard

onState() event doesn't fire on multiselect toggle

Open danielvy opened this issue 4 years ago • 1 comments

Describe the bug

onState() event doesn't fire when toggling an item in multi select prompt

To Reproduce

const items = await prompts({
	message: "Select items",
	type: "multiselect",
	name: "items",
	choices: [
		{value: "value1", title: "item1"},
		{value: "value2", title: "item2"}
	],
	onState(o) {
		console.log(o);
	}
});

Run and select/deselect items.

Expected behavior

onState() should fire when selecting/deselecting items in multi select.

System

  • OS: MacOS 10.14.6
  • Terminal: VSCode
  • Node version: 13.12.0

danielvy avatar Jun 29 '20 16:06 danielvy

@danielvy it looks like your callback is wrong though.

But the following doesn't fire on type select.

        {
          type: 'select',
          name: 'hello,
          message: 'Hello world?',
          choices: [
            { title: 'No', value: false },
            { title: 'Yes', value: true }
          ],
          onState: (prev, values) => {
            console.log(prev, values);
          }
        },

totszwai avatar Apr 30 '22 00:04 totszwai