From 497e5e118972df84a7d6c301602c9c5b8d01670c Mon Sep 17 00:00:00 2001 From: Hunter Johnston <64506580+huntabyte@users.noreply.github.com> Date: Sun, 8 Dec 2024 12:33:03 -0500 Subject: [PATCH] fix: `avoidCollisions` (#984) --- .changeset/heavy-boats-drive.md | 5 +++++ .../bits/utilities/floating-layer/useFloatingLayer.svelte.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/heavy-boats-drive.md diff --git a/.changeset/heavy-boats-drive.md b/.changeset/heavy-boats-drive.md new file mode 100644 index 000000000..1cd623307 --- /dev/null +++ b/.changeset/heavy-boats-drive.md @@ -0,0 +1,5 @@ +--- +"bits-ui": patch +--- + +fix: `avoidCollisions` in Floating UI components diff --git a/packages/bits-ui/src/lib/bits/utilities/floating-layer/useFloatingLayer.svelte.ts b/packages/bits-ui/src/lib/bits/utilities/floating-layer/useFloatingLayer.svelte.ts index 305c3353d..8857a1179 100644 --- a/packages/bits-ui/src/lib/bits/utilities/floating-layer/useFloatingLayer.svelte.ts +++ b/packages/bits-ui/src/lib/bits/utilities/floating-layer/useFloatingLayer.svelte.ts @@ -145,14 +145,14 @@ class FloatingContentState { mainAxis: this.#sideOffset.current + this.#arrowHeight, alignmentAxis: this.#alignOffset.current, }), - this.#avoidCollisions && + this.#avoidCollisions.current && shift({ mainAxis: true, crossAxis: false, limiter: this.#sticky.current === "partial" ? limitShift() : undefined, ...this.detectOverflowOptions, }), - this.#avoidCollisions && flip({ ...this.detectOverflowOptions }), + this.#avoidCollisions.current && flip({ ...this.detectOverflowOptions }), size({ ...this.detectOverflowOptions, apply: ({ rects, availableWidth, availableHeight }) => {