fix: correctly search for the tab fragment #405
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes issues in nested tabs where it can't find the fragment. Although it doesn't crash, the fragments enter a weird state where there are some leaks during navigations, which might or might not be related to this plugin.
The problem here is that the tab fragments are always added to the root manager (due to passing _context) on the fragment adapter. Ideally we should pass the child fragment manager but this seems to works on all the scenarios I tested (nested frames, single frame, tabs in modal, nested frames in modal).
My initial tests passing the correct manager resulted in a weird crash in the adapter constructor which might be related to picking the wrong constructor or just some weirdness on my test app, since this fix seemed to resolve all issues I decided to leave it as is, but anyone can continue the investigation if they'd like so we can identify the correct solution.