I'm using Headless UI as a part of the Tailwind UI's Vue implementation and Vue3 which work perfectly until Inertia is brought in.
The headless UI's ListboxOption
has a Selected
property which matches the Selected towards the model of the Listbox
and returns a boolean.
This is my Dropdown's script:
export default {
props: [
'modelValue', 'label', 'options'
],
data() {
return {
content: this.modelValue,
selected: null,
}
},
methods: {
handleInput (e) {
this.content = e;
this.$emit('update:modelValue', this.content)
},
},
components: {
Listbox,
ListboxButton,
ListboxLabel,
ListboxOption,
ListboxOptions,
CheckIcon,
SelectorIcon,
},
created() {
this.selected = this.modelValue != '' ? this.modelValue : this.options[0];
},
watch: {
selected(value) {
this.handleInput(value)
},
}
}
If I don't do anything in the parent component when emiting update modelValue it all works perfectly. Selected
is set properly etc.
When I do an Inertia.get with preserveState
I can see that the selected
property in the dropdown is updated and stays absolutely the same as when it works, but the selected
property of the ListboxOption returns false.