skeletonlabs / floating-ui-svelte

A Floating UI wrapper for Svelte
https://floating-ui-svelte.vercel.app
MIT License
155 stars 7 forks source link

Document SSR Floating Element Behavior #41

Closed endigo9740 closed 4 months ago

endigo9740 commented 5 months ago

By default, Svelte has SSR enabled. This means that you cannot wrap binded element references with #if statements, as the element will not be contained within the DOM.

We should provide some guidance around this. @Hugos68 suggested:

<div bind:this={elements.floating}>
  {#if floating.isPositioned}
       ...
  {/if}
</div>

But this seems to be affecting the position and stying in an adverse manner, so more research is needed.

References

endigo9740 commented 4 months ago

Note: this can now be added to the /docs/getting-started page. Let's added it towards the bottom.