@change does not work with Combobox (VueJs)
See original GitHub issueWhat package within Headless UI are you using?
What version of that package are you using?
v1.5.0
What browser are you using?
Chrome
Reproduction URL
A public GitHub repo that includes a minimal reproduction of the bug. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn’t matter if your real project is private/confidential, since we want a link to a separate, isolated reproduction anyways. Unfortunately we can’t provide support without a reproduction, and your issue will be closed with no comment if this is not provided.
Describe your issue
<Combobox
v-model="selectedPerson"
@change="window.location.href = selectedPerson.url"
as="div"
>
<ComboboxInput
placeholder="Search..."
@change="query = $event.target.value"
:displayValue="(person) => person.name"
/>
<ComboboxOptions
static
>
<ComboboxOption
v-slot="{ active }"
v-for="person in filteredPeople"
:disabled="person.unavailable"
:key="person.id"
:value="person"
>
</ComboboxOption>
</ComboboxOptions>
<Combobox/>
When there are actions like click
or enter
to the ComboxOption, the value in v-model="selectedPerson"
changed,.
I used @change
to catch all those changes and redirect the window to the respective URL
But it does not seem to be working, nothing happened after clicking
or entering
Before
clicking
orentering
After
clicking
orentering
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
In Vue we use v-model instead of custom props and events. To react to changes without using
computed
,watch
, etc… you need to use the same event used by v-model:update:modelValue
.Which, means the code above should be written as:
Link: https://stackblitz.com/edit/vue-sv3ctl
Aside:
console.count()
doesn’t work on StackBlitz console.@thecrypticace Not sure if there is a way to display activeOption in the ComboboxInput?