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
This commit is contained in:
Robin Malfait
2024-04-22 17:05:30 +02:00
committed by GitHub
parent 38551c8512
commit b4cda76f91
2 changed files with 2 additions and 7 deletions
+1
View File
@@ -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
@@ -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.