Skip to content

Commit 4acf9e2

Browse files
authored
Ensure the static and portal props work nicely together (#3152)
* ensure we keep the `static` prop into account when using the `<Portal/>` around anchored elements. * update changelog
1 parent 872808c commit 4acf9e2

File tree

5 files changed

+5
-4
lines changed

5 files changed

+5
-4
lines changed

packages/@headlessui-react/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Make sure `data-disabled` is available on virtualized options in the `Combobox` component ([#3128](https://github.com/tailwindlabs/headlessui/pull/3128))
2929
- Add `overflow: auto` when using the `anchor` prop ([#3138](https://github.com/tailwindlabs/headlessui/pull/3138))
3030
- Ensure `TransitionRoot` component without props transitions correctly ([#3147](https://github.com/tailwindlabs/headlessui/pull/3147))
31+
- Ensure the `static` and `portal` props work nicely together ([#3152](https://github.com/tailwindlabs/headlessui/pull/3152))
3132

3233
### Changed
3334

packages/@headlessui-react/src/components/combobox/combobox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(
16801680
})
16811681

16821682
return (
1683-
<Portal enabled={visible && portal}>
1683+
<Portal enabled={portal ? props.static || visible : false}>
16841684
<ComboboxDataContext.Provider
16851685
value={data.mode === ValueMode.Multi ? data : { ...data, isSelected }}
16861686
>

packages/@headlessui-react/src/components/listbox/listbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(
11101110
})
11111111

11121112
return (
1113-
<Portal enabled={visible && portal}>
1113+
<Portal enabled={portal ? props.static || visible : false}>
11141114
<ListboxDataContext.Provider
11151115
value={data.mode === ValueMode.Multi ? data : { ...data, isSelected }}
11161116
>

packages/@headlessui-react/src/components/menu/menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ function ItemsFn<TTag extends ElementType = typeof DEFAULT_ITEMS_TAG>(
783783
})
784784

785785
return (
786-
<Portal enabled={visible && portal}>
786+
<Portal enabled={portal ? props.static || visible : false}>
787787
{render({
788788
ourProps,
789789
theirProps,

packages/@headlessui-react/src/components/popover/popover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(
10151015
return (
10161016
<PopoverPanelContext.Provider value={id}>
10171017
<PopoverAPIContext.Provider value={{ close, isPortalled }}>
1018-
<Portal enabled={visible && portal}>
1018+
<Portal enabled={portal ? props.static || visible : false}>
10191019
{visible && isPortalled && (
10201020
<Hidden
10211021
id={beforePanelSentinelId}

0 commit comments

Comments
 (0)