diff --git a/nuxt4-app/app/components/UbicacionMultiSelector.vue b/nuxt4-app/app/components/UbicacionMultiSelector.vue index 8b42cdb..071d7a3 100644 --- a/nuxt4-app/app/components/UbicacionMultiSelector.vue +++ b/nuxt4-app/app/components/UbicacionMultiSelector.vue @@ -81,19 +81,33 @@ const selectedUbicacionesObjects = computed(() => { const filteredItems = computed((): InputMenuItem[] => { 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) { - return props.ubicaciones + return validUbicaciones } - return props.ubicaciones.filter(u => + return validUbicaciones.filter(u => u.label.toLowerCase().includes(query) ) }) // Methods function onSelectionChange(value: any[]) { + if (!Array.isArray(value)) { + emit('update:selectedUbicaciones', []) + return + } + // 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) }