fix: evitar uso de document en SSR en Popover.svelte

Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>
webui
borja 2 weeks ago
parent f4632859e0
commit 2074c8ed0b

@ -1,6 +1,7 @@
<script lang="ts">
import { tick, onDestroy } from 'svelte';
import { createEventDispatcher } from 'svelte';
import { browser } from '$app/environment';
export let open: boolean = false;
export let ariaLabel: string = 'Diálogo';
@ -47,20 +48,26 @@
}
$: if (open) {
lastActive = document.activeElement;
tick().then(() => {
panelEl?.focus();
document.body.style.overflow = 'hidden';
});
if (browser) {
lastActive = document.activeElement;
tick().then(() => {
panelEl?.focus();
document.body.style.overflow = 'hidden';
});
}
} else {
document.body.style.overflow = '';
if (lastActive instanceof HTMLElement) {
tick().then(() => lastActive?.focus());
if (browser) {
document.body.style.overflow = '';
if (lastActive instanceof HTMLElement) {
tick().then(() => lastActive?.focus());
}
}
}
onDestroy(() => {
document.body.style.overflow = '';
if (browser) {
document.body.style.overflow = '';
}
});
</script>

Loading…
Cancel
Save