diff --git a/src/components/UI/BasePopover.vue b/src/components/UI/BasePopover.vue index 89a50e1..1251ba2 100644 --- a/src/components/UI/BasePopover.vue +++ b/src/components/UI/BasePopover.vue @@ -38,13 +38,30 @@ const emit = defineEmits<{ (e: 'close'): void }>() -const unwrapToElement = (maybeEl: unknown): HTMLElement | null => { - if (!maybeEl) return null - +function unwrapToElement(maybeEl: unknown): HTMLElement | null { if (maybeEl instanceof HTMLElement) return maybeEl - if (maybeEl.$el instanceof HTMLElement) return maybeEl.$el as HTMLElement - if (maybeEl.$el?.value instanceof HTMLElement) return maybeEl.$el.value as HTMLElement - if (maybeEl.value instanceof HTMLElement) return maybeEl.value as HTMLElement + + if (maybeEl && typeof maybeEl === 'object') { + const obj = maybeEl as Record + + if ('$el' in obj) { + const $el = (obj as { $el?: unknown }).$el + if ($el instanceof HTMLElement) return $el + if ($el && typeof $el === 'object' && 'value' in ($el as Record)) { + const v = ($el as { value?: unknown }).value + if (v instanceof HTMLElement) return v + } + } + + if ('value' in obj) { + const v = (obj as { value?: unknown }).value + if (v instanceof HTMLElement) return v + if (v && typeof v === 'object' && '$el' in (v as Record)) { + const nested = (v as { $el?: unknown }).$el + if (nested instanceof HTMLElement) return nested + } + } + } return null }