mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-31 12:17:54 +01:00
fix(SelectMenu): handle Boolean type as model value (#1550)
Co-authored-by: chenying <chenying@addcn.com> Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -50,7 +50,7 @@ componentProps:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
If you only want to select a single object property rather than the whole object as value, you can set the `value-attribute` property. This prop defaults to `null`.
|
If you only want to select a single object property rather than the whole object as value, you can set the `value-attribute` property. This prop defaults to `null`.The value of the `value-attribute` field in options must be unique.
|
||||||
|
|
||||||
::component-example
|
::component-example
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ export default defineComponent({
|
|||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [String, Number, Object, Array],
|
type: [String, Number, Object, Array, Boolean],
|
||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
query: {
|
query: {
|
||||||
@@ -362,7 +362,7 @@ export default defineComponent({
|
|||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
} else if (props.modelValue) {
|
} else if (props.modelValue !== undefined && props.modelValue !== null) {
|
||||||
if (props.valueAttribute) {
|
if (props.valueAttribute) {
|
||||||
const option = props.options.find(option => option[props.valueAttribute] === props.modelValue)
|
const option = props.options.find(option => option[props.valueAttribute] === props.modelValue)
|
||||||
return option ? option[props.optionAttribute] : null
|
return option ? option[props.optionAttribute] : null
|
||||||
@@ -387,7 +387,7 @@ export default defineComponent({
|
|||||||
variant?.replaceAll('{color}', color.value),
|
variant?.replaceAll('{color}', color.value),
|
||||||
(isLeading.value || slots.leading) && ui.value.leading.padding[size.value],
|
(isLeading.value || slots.leading) && ui.value.leading.padding[size.value],
|
||||||
(isTrailing.value || slots.trailing) && ui.value.trailing.padding[size.value]
|
(isTrailing.value || slots.trailing) && ui.value.trailing.padding[size.value]
|
||||||
), props.placeholder && !props.modelValue && ui.value.placeholder, props.selectClass)
|
), props.placeholder && (props.modelValue === undefined && props.modelValue === null) && ui.value.placeholder, props.selectClass)
|
||||||
})
|
})
|
||||||
|
|
||||||
const isLeading = computed(() => {
|
const isLeading = computed(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user