From b4cda76f91324e5bf9f6dccbbfaa2378f12991f2 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 22 Apr 2024 17:05:30 +0200 Subject: [PATCH] Remove the `anchor.strategy` option (#3120) * remove the `strategy` options, use "absolute" by default Right now there is no good reason to expose the strategy, because the default is good performance wise, and using `absolute` is fine because we are portalled so there is no parent relative container to worry about. * update changelog --- packages/@headlessui-react/CHANGELOG.md | 1 + packages/@headlessui-react/src/internal/floating.tsx | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/@headlessui-react/CHANGELOG.md b/packages/@headlessui-react/CHANGELOG.md index f0a466d..ab91c27 100644 --- a/packages/@headlessui-react/CHANGELOG.md +++ b/packages/@headlessui-react/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Use `absolute` as the default Floating UI strategy ([#3097](https://github.com/tailwindlabs/headlessui/pull/3097)) - Change default tags for `ListboxOptions`, `ListboxOption`, `ComboboxOptions`, `ComboboxOption` and `TabGroup` components ([#3109](https://github.com/tailwindlabs/headlessui/pull/3109)) - Change default tag from `div` to `Fragment` on `Transition` components ([#3110](https://github.com/tailwindlabs/headlessui/pull/3110)) +- Remove the `anchor.strategy` option ([#3120](https://github.com/tailwindlabs/headlessui/pull/3120)) ### Added diff --git a/packages/@headlessui-react/src/internal/floating.tsx b/packages/@headlessui-react/src/internal/floating.tsx index 2a67a2d..e602d81 100644 --- a/packages/@headlessui-react/src/internal/floating.tsx +++ b/packages/@headlessui-react/src/internal/floating.tsx @@ -21,11 +21,6 @@ type Align = 'start' | 'end' type Placement = 'top' | 'right' | 'bottom' | 'left' type BaseAnchorProps = { - /** - * The strategy to use when positioning the panel. Defaults to `absolute`. - */ - strategy: 'absolute' | 'fixed' - /** * The `gap` is the space between the trigger and the panel. */ @@ -171,7 +166,6 @@ export function FloatingProvider({ offset = 0, padding = 0, inner, - strategy = 'absolute', } = useResolvedConfig(config, floatingEl) let [to, align = 'center'] = placement.split(' ') as [Placement | 'selection', Align | 'center'] @@ -195,7 +189,7 @@ export function FloatingProvider({ // This component will be used in combination with a `Portal`, which means the floating // element will be rendered outside of the current DOM tree. - strategy, + strategy: 'absolute', // We use the panel in a `Dialog` which is making the page inert, therefore no re-positioning is // needed when scrolling changes.