You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ensure ref is always connected when rendering in Portal (#3789)
This PR fixes an issue where elements of a `<Portal />` were not
connected on subsequent renders.
Our Portal component is relatively complex because we want to make sure
we use the correct `document`, only keep a single portal root (and clean
it up when there are no more portals) and each portal gets its own `<div
data-headlessui-portal>`.
This is also where the bug was, because we were creating the
`data-headlessui-portal` div manually.
Cleaning all that up, and let React take care of most of that fixes the
issue as well.
## Test plan
1. All existing tests pass
2. Elements are now connected on subsequent renders, verified using the
reproduction steps in #3681
Before:
https://github.com/user-attachments/assets/28dde5de-505e-4f2c-bf34-2feb4fe8fac7
After:
https://github.com/user-attachments/assets/d54cfa6a-8d86-47e7-9c5b-dbc620a86ef8Fixes: #3681
Copy file name to clipboardExpand all lines: packages/@headlessui-react/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
16
16
- Ensure pressing `Tab` in the `ComboboxInput`, correctly syncs the input value ([#3785](https://github.com/tailwindlabs/headlessui/pull/3785))
17
17
- Ensure `--button-width` and `--input-width` have the latest value ([#3786](https://github.com/tailwindlabs/headlessui/pull/3786))
18
18
- Fix 'Invalid prop `data-headlessui-state` supplied to `React.Fragment`' warning ([#3788](https://github.com/tailwindlabs/headlessui/pull/3788))
19
+
- Ensure `element` in `ref` callback is always connected when rendering in a `Portal` ([#3789](https://github.com/tailwindlabs/headlessui/pull/3789))
0 commit comments