Skip to content

Update to upstream @floating-ui/core@1.7.0#135

Merged
DanielleHuisman merged 3 commits intomainfrom
upstream/core-1.7.0
May 4, 2025
Merged

Update to upstream @floating-ui/core@1.7.0#135
DanielleHuisman merged 3 commits intomainfrom
upstream/core-1.7.0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 2, 2025

Release
@floating-ui/core@1.7.0

Diff for packages/core

Diff
diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md
index 1ac46796..e9067daf 100644
--- a/packages/core/CHANGELOG.md
+++ b/packages/core/CHANGELOG.md
@@ -1,5 +1,11 @@
 # @floating-ui/core
 
+## 1.7.0
+
+### Minor Changes
+
+- feat(flip): add `"alignment"` string value for `crossAxis` option. This value determines if cross axis overflow checking is restricted to the `alignment` of the placement only. This prevents `fallbackPlacements`/`fallbackAxisSideDirection` from too eagerly changing to the perpendicular side (thereby preferring `shift()` if overflow is detected along the cross axis, even if `shift()` is placed after `flip()` in the middleware array).
+
 ## 1.6.9
 
 ### Patch Changes
diff --git a/packages/core/package.json b/packages/core/package.json
index dfc54ff9..82b1e972 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@floating-ui/core",
-  "version": "1.6.9",
+  "version": "1.7.0",
   "description": "Positioning library for floating elements: tooltips, popovers, dropdowns, and more",
   "publishConfig": {
     "access": "public"
diff --git a/packages/core/src/middleware/flip.ts b/packages/core/src/middleware/flip.ts
index b2ccf911..f2a551eb 100644
--- a/packages/core/src/middleware/flip.ts
+++ b/packages/core/src/middleware/flip.ts
@@ -23,9 +23,12 @@ export interface FlipOptions extends DetectOverflowOptions {
   /**
    * The axis that runs along the alignment of the floating element. Determines
    * whether overflow along this axis is checked to perform a flip.
+   * - `true`: Whether to check cross axis overflow for both side and alignment flipping.
+   * - `false`: Whether to disable all cross axis overflow checking.
+   * - `'alignment'`: Whether to check cross axis overflow for alignment flipping only.
    * @default true
    */
-  crossAxis?: boolean;
+  crossAxis?: boolean | 'alignment';
   /**
    * Placements to try sequentially if the preferred `placement` does not fit.
    * @default [oppositePlacement] (computed)
@@ -137,16 +140,24 @@ export const flip = (
       const nextPlacement = placements[nextIndex];
 
       if (nextPlacement) {
-        // Try next placement and re-run the lifecycle.
-        return {
-          data: {
-            index: nextIndex,
-            overflows: overflowsData,
-          },
-          reset: {
-            placement: nextPlacement,
-          },
-        };
+        const ignoreCrossAxisOverflow =
+          checkCrossAxis === 'alignment'
+            ? initialSideAxis !== getSideAxis(nextPlacement)
+            : false;
+        const hasInitialMainAxisOverflow = overflowsData[0]?.overflows[0] > 0;
+
+        if (!ignoreCrossAxisOverflow || hasInitialMainAxisOverflow) {
+          // Try next placement and re-run the lifecycle.
+          return {
+            data: {
+              index: nextIndex,
+              overflows: overflowsData,
+            },
+            reset: {
+              placement: nextPlacement,
+            },
+          };
+        }
       }
 
       // First, find the candidates that fit on the mainAxis side of overflow,

Full diff
1.6.9...1.7.0.

@DanielleHuisman DanielleHuisman marked this pull request as ready for review May 4, 2025 18:34
@DanielleHuisman DanielleHuisman merged commit 486f119 into main May 4, 2025
8 checks passed
@DanielleHuisman DanielleHuisman deleted the upstream/core-1.7.0 branch May 4, 2025 18:56
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.

1 participant