mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-30 11:47:55 +01:00
fix(InputMenu/SelectMenu): look in items only with value-attribute
Resolves #2464
This commit is contained in:
@@ -179,13 +179,17 @@ const ui = computed(() => inputMenu({
|
|||||||
buttonGroup: orientation.value
|
buttonGroup: orientation.value
|
||||||
}))
|
}))
|
||||||
|
|
||||||
function displayValue(value: AcceptableValue): string {
|
function displayValue(value: T): string {
|
||||||
const item = items.value.find(item => props.valueKey ? isEqual(get(item as Record<string, any>, props.valueKey as string), value) : isEqual(item, value))
|
if (!props.valueKey) {
|
||||||
|
return value && (typeof value === 'object' ? get(value, props.labelKey as string) : value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const item = items.value.find(item => isEqual(get(item as Record<string, any>, props.valueKey as string), value))
|
||||||
|
|
||||||
return item && (typeof item === 'object' ? get(item, props.labelKey as string) : item)
|
return item && (typeof item === 'object' ? get(item, props.labelKey as string) : item)
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterFunction(items: ArrayOrWrapped<AcceptableValue>, searchTerm: string): ArrayOrWrapped<AcceptableValue> {
|
function filterFunction(items: ArrayOrWrapped<T>, searchTerm: string): ArrayOrWrapped<T> {
|
||||||
if (props.filter === false) {
|
if (props.filter === false) {
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,10 +170,14 @@ const ui = computed(() => selectMenu({
|
|||||||
|
|
||||||
function displayValue(value: T | T[]): string {
|
function displayValue(value: T | T[]): string {
|
||||||
if (props.multiple && Array.isArray(value)) {
|
if (props.multiple && Array.isArray(value)) {
|
||||||
return value.map(v => displayValue(v)).join(', ')
|
return value.map(v => displayValue(v)).filter(Boolean).join(', ')
|
||||||
}
|
}
|
||||||
|
|
||||||
const item = items.value.find(item => props.valueKey ? isEqual(get(item as Record<string, any>, props.valueKey as string), value) : isEqual(item, value))
|
if (!props.valueKey) {
|
||||||
|
return value && (typeof value === 'object' ? get(value, props.labelKey as string) : value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const item = items.value.find(item => isEqual(get(item as Record<string, any>, props.valueKey as string), value))
|
||||||
|
|
||||||
return item && (typeof item === 'object' ? get(item, props.labelKey as string) : item)
|
return item && (typeof item === 'object' ? get(item, props.labelKey as string) : item)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user