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
|
className
|
||||||
)}
|
)}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
/>
|
>
|
||||||
|
{@render restProps.children?.()}
|
||||||
|
</DropdownMenuPrimitive.Content>
|
||||||
</DropdownMenuPrimitive.Portal>
|
</DropdownMenuPrimitive.Portal>
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,6 @@
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
/>
|
>
|
||||||
|
{@render restProps.children?.()}
|
||||||
|
</DropdownMenuPrimitive.Item>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
|
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
|
||||||
|
import { browser } from "$app/environment";
|
||||||
|
|
||||||
let {
|
let {
|
||||||
ref = $bindable(null),
|
ref = $bindable(null),
|
||||||
|
|
@ -7,8 +8,22 @@
|
||||||
}: DropdownMenuPrimitive.TriggerProps = $props();
|
}: DropdownMenuPrimitive.TriggerProps = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if browser}
|
||||||
<DropdownMenuPrimitive.Trigger
|
<DropdownMenuPrimitive.Trigger
|
||||||
bind:ref
|
bind:ref
|
||||||
data-slot="dropdown-menu-trigger"
|
data-slot="dropdown-menu-trigger"
|
||||||
{...restProps}
|
{...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