Commit afe3420
fix: remove NavView fragment via the FragmentManager it is attached to
NavViewManager.onDropViewInstance removed the map/navigation fragment
through reactContext.getCurrentActivity()'s support FragmentManager.
When the view is dropped while getCurrentActivity() points at a
different Activity than the one hosting the fragment (e.g. after
Activity recreation), that FragmentManager never hosted the fragment
and androidx throws:
IllegalStateException: Cannot remove Fragment attached to a different
FragmentManager
Use the fragment's own getParentFragmentManager() for the remove
transaction instead, and guard against the FragmentManager being
already destroyed mid-teardown. This also no longer skips cleanup
(leaking the fragmentMap entry) when getCurrentActivity() is null.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 0b1819c commit afe3420
1 file changed
Lines changed: 14 additions & 8 deletions
File tree
Lines changed: 14 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | 307 | | |
311 | 308 | | |
312 | 309 | | |
313 | 310 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
319 | 325 | | |
320 | 326 | | |
321 | 327 | | |
| |||
0 commit comments