Add null as a valid type for Listbox and Combobox in Vue (#2064)
* add `null` as a valid type for Listbox and Combobox in Vue * update changelog
This commit is contained in:
@@ -456,6 +456,30 @@ describe('Rendering', () => {
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it(
|
||||
'null should be a valid value for the Listbox',
|
||||
suppressConsoleLogs(async () => {
|
||||
render(
|
||||
<Listbox value={null} onChange={console.log}>
|
||||
<Listbox.Button>Trigger</Listbox.Button>
|
||||
<Listbox.Options>
|
||||
<Listbox.Option value="a">Option A</Listbox.Option>
|
||||
<Listbox.Option value="b">Option B</Listbox.Option>
|
||||
<Listbox.Option value="c">Option C</Listbox.Option>
|
||||
</Listbox.Options>
|
||||
</Listbox>
|
||||
)
|
||||
|
||||
assertListboxButton({ state: ListboxState.InvisibleUnmounted })
|
||||
assertListbox({ state: ListboxState.InvisibleUnmounted })
|
||||
|
||||
await click(getListboxButton())
|
||||
|
||||
assertListboxButton({ state: ListboxState.Visible })
|
||||
assertListbox({ state: ListboxState.Visible })
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
describe('Listbox.Label', () => {
|
||||
|
||||
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Improve syncing of the `ComboboxInput` value ([#2042](https://github.com/tailwindlabs/headlessui/pull/2042))
|
||||
- Fix crash when using `multiple` mode without `value` prop (uncontrolled) for `Listbox` and `Combobox` components ([#2058](https://github.com/tailwindlabs/headlessui/pull/2058))
|
||||
- Allow passing in your own `id` prop ([#2060](https://github.com/tailwindlabs/headlessui/pull/2060))
|
||||
- Add `null` as a valid type for Listbox and Combobox in Vue ([#2064](https://github.com/tailwindlabs/headlessui/pull/2064))
|
||||
|
||||
## [1.7.4] - 2022-11-03
|
||||
|
||||
|
||||
@@ -118,7 +118,12 @@ export let Combobox = defineComponent({
|
||||
as: { type: [Object, String], default: 'template' },
|
||||
disabled: { type: [Boolean], default: false },
|
||||
by: { type: [String, Function], default: () => defaultComparator },
|
||||
modelValue: { type: [Object, String, Number, Boolean], default: undefined },
|
||||
modelValue: {
|
||||
type: [Object, String, Number, Boolean] as PropType<
|
||||
object | string | number | boolean | null
|
||||
>,
|
||||
default: undefined,
|
||||
},
|
||||
defaultValue: { type: [Object, String, Number, Boolean], default: undefined },
|
||||
name: { type: String },
|
||||
nullable: { type: Boolean, default: false },
|
||||
|
||||
@@ -495,6 +495,33 @@ describe('Rendering', () => {
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it(
|
||||
'null should be a valid value for the Listbox',
|
||||
suppressConsoleLogs(async () => {
|
||||
renderTemplate({
|
||||
template: html`
|
||||
<Listbox v-model="value" by="id">
|
||||
<ListboxButton>Trigger</ListboxButton>
|
||||
<ListboxOptions>
|
||||
<ListboxOption :value="{ id: 1, name: 'alice' }">alice</ListboxOption>
|
||||
<ListboxOption :value="{ id: 2, name: 'bob' }">bob</ListboxOption>
|
||||
<ListboxOption :value="{ id: 3, name: 'charlie' }">charlie</ListboxOption>
|
||||
</ListboxOptions>
|
||||
</Listbox>
|
||||
`,
|
||||
setup: () => ({ value: null }),
|
||||
})
|
||||
|
||||
assertListboxButton({ state: ListboxState.InvisibleUnmounted })
|
||||
assertListbox({ state: ListboxState.InvisibleUnmounted })
|
||||
|
||||
await click(getListboxButton())
|
||||
|
||||
assertListboxButton({ state: ListboxState.Visible })
|
||||
assertListbox({ state: ListboxState.Visible })
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
describe('ListboxLabel', () => {
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
InjectionKey,
|
||||
Ref,
|
||||
UnwrapNestedRefs,
|
||||
PropType,
|
||||
} from 'vue'
|
||||
|
||||
import { Features, render, omit, compact } from '../../utils/render'
|
||||
@@ -119,7 +120,12 @@ export let Listbox = defineComponent({
|
||||
disabled: { type: [Boolean], default: false },
|
||||
by: { type: [String, Function], default: () => defaultComparator },
|
||||
horizontal: { type: [Boolean], default: false },
|
||||
modelValue: { type: [Object, String, Number, Boolean], default: undefined },
|
||||
modelValue: {
|
||||
type: [Object, String, Number, Boolean] as PropType<
|
||||
object | string | number | boolean | null
|
||||
>,
|
||||
default: undefined,
|
||||
},
|
||||
defaultValue: { type: [Object, String, Number, Boolean], default: undefined },
|
||||
name: { type: String, optional: true },
|
||||
multiple: { type: [Boolean], default: false },
|
||||
|
||||
Reference in New Issue
Block a user