Fix: Corregir error de toLowerCase y selección múltiple en ubicaciones
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 46s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 46s
Problemas corregidos: 1. Error "Cannot read properties of undefined (reading 'toLowerCase')": - Agregar validación para filtrar items undefined/null - Verificar que cada item tenga label y value antes de usar toLowerCase - Prevenir errores cuando el array de ubicaciones tiene items inválidos 2. Selección múltiple no funcionaba: - Mejorar onSelectionChange para manejar diferentes tipos de valores - Agregar validación de array antes de procesar - Filtrar items null/undefined antes de extraer valores - Manejar tanto objetos como strings en el array de valores 3. Tags no aparecían en el input: - El problema estaba en el procesamiento de valores seleccionados - Ahora maneja correctamente item.value y strings directos El componente ahora funciona igual que ClienteMultiSelector: - Sin errores en consola - Tags visuales aparecen correctamente - Selección múltiple funciona perfectamente
This commit is contained in:
@@ -81,19 +81,33 @@ const selectedUbicacionesObjects = computed(() => {
|
|||||||
const filteredItems = computed((): InputMenuItem[] => {
|
const filteredItems = computed((): InputMenuItem[] => {
|
||||||
const query = searchQuery.value.trim().toLowerCase()
|
const query = searchQuery.value.trim().toLowerCase()
|
||||||
|
|
||||||
|
// Filter out undefined/null items and ensure they have label and value
|
||||||
|
const validUbicaciones = props.ubicaciones.filter(u => u && u.label && u.value)
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
return props.ubicaciones
|
return validUbicaciones
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.ubicaciones.filter(u =>
|
return validUbicaciones.filter(u =>
|
||||||
u.label.toLowerCase().includes(query)
|
u.label.toLowerCase().includes(query)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
function onSelectionChange(value: any[]) {
|
function onSelectionChange(value: any[]) {
|
||||||
|
if (!Array.isArray(value)) {
|
||||||
|
emit('update:selectedUbicaciones', [])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Extract values from selected items
|
// Extract values from selected items
|
||||||
const values = value.map(item => item.value || item)
|
const values = value
|
||||||
|
.filter(item => item && (item.value || typeof item === 'string'))
|
||||||
|
.map(item => {
|
||||||
|
if (typeof item === 'string') return item
|
||||||
|
return item.value || item
|
||||||
|
})
|
||||||
|
|
||||||
emit('update:selectedUbicaciones', values)
|
emit('update:selectedUbicaciones', values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user