Commit 030773c
authored
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-dbc620a86ef8
Fixes: #3681
1 parent 9dc83e0 commit 030773c
File tree
2 files changed
+26
-42
lines changed- packages/@headlessui-react
- src/components/portal
2 files changed
+26
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
Lines changed: 25 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | | - | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | | - | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
| |||
94 | 92 | | |
95 | 93 | | |
96 | 94 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | 95 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 96 | + | |
| 97 | + | |
120 | 98 | | |
121 | 99 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 100 | + | |
127 | 101 | | |
| 102 | + | |
128 | 103 | | |
129 | 104 | | |
130 | 105 | | |
131 | 106 | | |
132 | 107 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 108 | | |
137 | 109 | | |
138 | | - | |
| 110 | + | |
139 | 111 | | |
140 | 112 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
149 | 132 | | |
150 | 133 | | |
151 | 134 | | |
| |||
0 commit comments