Skip to content

Conversation

@github-actions
Copy link
Contributor

Release
@floating-ui/core@1.6.2

Diff for packages/core

Diff
diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md
index 6b800c2e..5364c5b8 100644
--- a/packages/core/CHANGELOG.md
+++ b/packages/core/CHANGELOG.md
@@ -1,5 +1,11 @@
 # @floating-ui/core
 
+## 1.6.2
+
+### Patch Changes
+
+- fix(size): correctly constrain floating element to avoid overflowing outside viewport with `shift({crossAxis: true})`
+
 ## 1.6.1
 
 ### Patch Changes
diff --git a/packages/core/package.json b/packages/core/package.json
index 9e51d594..216e5619 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@floating-ui/core",
-  "version": "1.6.1",
+  "version": "1.6.2",
   "description": "Positioning library for floating elements: tooltips, popovers, dropdowns, and more",
   "publishConfig": {
     "access": "public"
diff --git a/packages/core/src/middleware/size.ts b/packages/core/src/middleware/size.ts
index a95ccce6..9d27eddd 100644
--- a/packages/core/src/middleware/size.ts
+++ b/packages/core/src/middleware/size.ts
@@ -67,8 +67,17 @@ export const size = (
       heightSide = alignment === 'end' ? 'top' : 'bottom';
     }
 
-    const overflowAvailableHeight = height - overflow[heightSide];
-    const overflowAvailableWidth = width - overflow[widthSide];
+    const maximumClippingHeight = height - overflow.top - overflow.bottom;
+    const maximumClippingWidth = width - overflow.left - overflow.right;
+
+    const overflowAvailableHeight = min(
+      height - overflow[heightSide],
+      maximumClippingHeight,
+    );
+    const overflowAvailableWidth = min(
+      width - overflow[widthSide],
+      maximumClippingWidth,
+    );
 
     const noShift = !state.middlewareData.shift;
 
@@ -76,13 +85,11 @@ export const size = (
     let availableWidth = overflowAvailableWidth;
 
     if (isYAxis) {
-      const maximumClippingWidth = width - overflow.left - overflow.right;
       availableWidth =
         alignment || noShift
           ? min(overflowAvailableWidth, maximumClippingWidth)
           : maximumClippingWidth;
     } else {
-      const maximumClippingHeight = height - overflow.top - overflow.bottom;
       availableHeight =
         alignment || noShift
           ? min(overflowAvailableHeight, maximumClippingHeight)

Full diff
1.6.1...1.6.2.

@DanielleHuisman DanielleHuisman marked this pull request as ready for review May 15, 2024 17:06
@DanielleHuisman DanielleHuisman enabled auto-merge (squash) May 15, 2024 17:06
@DanielleHuisman DanielleHuisman merged commit 538dd2b into main May 15, 2024
@DanielleHuisman DanielleHuisman deleted the upstream/core-1.6.2 branch May 15, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants