fix(usePortal): adjust portal target resolution logic (#3954)

This commit is contained in:
Nathanaël Louison
2025-04-22 12:05:14 +02:00
committed by GitHub
parent 50863635d6
commit db11db6ff1

View File

@@ -6,11 +6,11 @@ export function usePortal(portal: Ref<string | HTMLElement | boolean | undefined
const portalTarget = inject(portalTargetInjectionKey, undefined)
const to = computed(() => {
if (typeof portal.value === 'string' || portal.value instanceof HTMLElement) {
return portal.value
if (typeof portal.value === 'boolean' || portal.value === undefined) {
return portalTarget?.value ?? 'body'
}
return portalTarget?.value ?? 'body'
return portal.value
})
const disabled = computed(() => typeof portal.value === 'boolean' ? !portal.value : false)