fix ssr
This commit is contained in:
parent
889948e5c7
commit
6e4e8a4eaa
3 changed files with 26 additions and 7 deletions
|
|
@ -23,5 +23,7 @@
|
|||
className
|
||||
)}
|
||||
{...restProps}
|
||||
/>
|
||||
>
|
||||
{@render restProps.children?.()}
|
||||
</DropdownMenuPrimitive.Content>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
|
|
|
|||
|
|
@ -24,4 +24,6 @@
|
|||
className
|
||||
)}
|
||||
{...restProps}
|
||||
/>
|
||||
>
|
||||
{@render restProps.children?.()}
|
||||
</DropdownMenuPrimitive.Item>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
|
||||
import { browser } from "$app/environment";
|
||||
|
||||
let {
|
||||
ref = $bindable(null),
|
||||
|
|
@ -7,8 +8,22 @@
|
|||
}: DropdownMenuPrimitive.TriggerProps = $props();
|
||||
</script>
|
||||
|
||||
<DropdownMenuPrimitive.Trigger
|
||||
{#if browser}
|
||||
<DropdownMenuPrimitive.Trigger
|
||||
bind:ref
|
||||
data-slot="dropdown-menu-trigger"
|
||||
{...restProps}
|
||||
/>
|
||||
>
|
||||
{@render restProps.children?.()}
|
||||
</DropdownMenuPrimitive.Trigger>
|
||||
{:else}
|
||||
<!-- SSR fallback -->
|
||||
<button
|
||||
bind:this={ref}
|
||||
data-slot="dropdown-menu-trigger"
|
||||
type="button"
|
||||
{...restProps}
|
||||
>
|
||||
{@render restProps.children?.()}
|
||||
</button>
|
||||
{/if}
|
||||
|
|
|
|||
Reference in a new issue