Commit 0374a51
committed
fix(desktop): post SET_MODE on iframe load + simplify pool ref registration
Two bugs in the preview-pool rewrite:
- The rewrite dropped the iframe's `onLoad` handler that (re)posted
SET_MODE. The parent's currentDesignId useEffect can fire before the
iframe document finishes loading, so its initial SET_MODE postMessage
may land on an unready message handler. Result: comment mode sometimes
failed to activate on a freshly-mounted pool iframe. Restore the
per-slot onLoad, gated on `active` so background iframes don't adopt
the foreground mode.
- `registerIframe` closed over `currentDesignId`, so every design switch
re-created the callback and React re-attached every pool iframe's ref.
Simplify it to pure map bookkeeping — the existing useEffect that runs
on currentDesignId change already retargets `iframeRef` by looking the
active id up in the map (child ref callbacks fire before parent
effects, so the map is populated by then).1 parent 8cbcf44 commit 0374a51
1 file changed
Lines changed: 23 additions & 14 deletions
Lines changed: 23 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
125 | 126 | | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
139 | 141 | | |
140 | 142 | | |
141 | 143 | | |
| 144 | + | |
142 | 145 | | |
| 146 | + | |
143 | 147 | | |
144 | 148 | | |
145 | 149 | | |
| |||
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
174 | 188 | | |
175 | 189 | | |
176 | 190 | | |
| |||
267 | 281 | | |
268 | 282 | | |
269 | 283 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
284 | 291 | | |
285 | 292 | | |
286 | 293 | | |
| |||
427 | 434 | | |
428 | 435 | | |
429 | 436 | | |
| 437 | + | |
430 | 438 | | |
| 439 | + | |
431 | 440 | | |
432 | 441 | | |
433 | 442 | | |
| |||
0 commit comments