Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly search for the tab fragment #405

Merged
merged 1 commit into from
Sep 16, 2022

Conversation

edusperoni
Copy link
Contributor

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.

@farfromrefug
Copy link
Member

@edusperoni awesome. Could we maybe add a comment about the fact that passing the child fragment manager would be best?

@edusperoni
Copy link
Contributor Author

edusperoni commented Sep 16, 2022

With the way NativeScript is doing fragments, we're always using the "closest" parent fragment to be the parent:

How it should be:

root fragment (activity)
| some frame+page
| | some frame+page
| | | tab fragment index 1
| | | | other things at index 1
| | | tab fragment index 2
| | | | other things at index 2
| some other frame+page

How it is:

root fragment (activity)
| some frame+page
| | some frame+page
| tab fragment index 1
| | other things at index 1
| tab fragment index 2
| | other things at index 2
| some other frame+page

essentially we're attaching the tab fragments in the root instead of the closes fragment in the hierarchy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants