Skip to content

Commit 336faab

Browse files
authored
Ensure that you can close the Combobox initially (#1148)
* ensure that you can close the combobox initially The issue is that `onInput` fires on every keystroke, and we also handled `onChange` which is triggered on blur in Vue. This means that the moment we blur, we also called the `handleChange` code to re-open the combobox because we want to open the combobox if something changes when the user starts typing. To fix this, we will splitup the logic so that it will only open the combobox on input but not on change. * update changelog
1 parent 475568b commit 336faab

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Fixed
1515

1616
- Make sure that the input syncs when the combobox closes ([#1137](https://github.com/tailwindlabs/headlessui/pull/1137))
17+
- Ensure that you can close the combobox initially ([#1148](https://github.com/tailwindlabs/headlessui/pull/1148))
1718

1819
## [@headlessui/react@v1.5.0] - 2022-02-17
1920

packages/@headlessui-vue/src/components/combobox/combobox.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ export let ComboboxInput = defineComponent({
499499
}
500500

501501
function handleChange(event: Event & { target: HTMLInputElement }) {
502+
emit('change', event)
503+
}
504+
505+
function handleInput(event: Event & { target: HTMLInputElement }) {
502506
api.openCombobox()
503507
emit('change', event)
504508
}
@@ -516,7 +520,7 @@ export let ComboboxInput = defineComponent({
516520
id,
517521
onKeydown: handleKeyDown,
518522
onChange: handleChange,
519-
onInput: handleChange,
523+
onInput: handleInput,
520524
role: 'combobox',
521525
type: 'text',
522526
tabIndex: 0,

0 commit comments

Comments
 (0)