Commit 3d046b4
authored
Inspector: Fix Firefox error reading child window bounds after close (#18389)
> 🤖 *This PR was created by the create-pr skill.*
## Problem
In `ChildWindow`
(`packages/dev/sharedUiComponents/src/fluent/hoc/childWindow.tsx`), the
dispose action that persists the child window's bounds to `localStorage`
reads `screenX`/`screenY`/`innerWidth`/`innerHeight` directly off the
child `Window`. In Firefox, accessing these properties after the window
has closed throws — which is exactly what happens when the user closes
the popout (the `unload` handler clears `childWindow` state, the effect
re-runs, and the cleanup fires while `childWindow.closed === true`).
## Fix
Cache the bounds while the window is still alive and use the cached
value at dispose time:
- Added a `getBounds()` helper.
- Initialize `lastBounds` eagerly when the window opens, so a value is
always available even if no later capture happens.
- Refresh `lastBounds` in a `beforeunload` listener (fires before the
window is destroyed in every close path).
- At dispose, refresh once more if the window is still open, then write
`lastBounds` to `localStorage`.
This eliminates the throw in Firefox while preserving the existing
bounds-restore behavior in all browsers.
## Files changed
- `packages/dev/sharedUiComponents/src/fluent/hoc/childWindow.tsx`1 parent 90d5490 commit 3d046b4
1 file changed
Lines changed: 22 additions & 9 deletions
File tree
Lines changed: 22 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
194 | 205 | | |
195 | 206 | | |
196 | 207 | | |
| |||
200 | 211 | | |
201 | 212 | | |
202 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
203 | 221 | | |
204 | 222 | | |
205 | 223 | | |
| |||
213 | 231 | | |
214 | 232 | | |
215 | 233 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
225 | 238 | | |
226 | 239 | | |
227 | 240 | | |
| |||
0 commit comments