Skip to content

fix(android): Corrected TabView fragment manager resolution#11228

Open
CatchABus wants to merge 5 commits into
NativeScript:mainfrom
CatchABus:fix/android-tabview-fragmentmanager
Open

fix(android): Corrected TabView fragment manager resolution#11228
CatchABus wants to merge 5 commits into
NativeScript:mainfrom
CatchABus:fix/android-tabview-fragmentmanager

Conversation

@CatchABus
Copy link
Copy Markdown
Contributor

@CatchABus CatchABus commented May 24, 2026

PR Checklist

What is the current behavior?

This is the second attempt after #11217.
Apparently, entering tab item loaded lifecycle during adapter attach is too early and tab frame fragments don't get enough time to be added to the correct fragment manager.

What is the new behavior?

This PR takes a few things from ui-material tabs plugin:

  • Uses the fragment onCreateView/onDestroyView fragment lifecycles to ensure view loaded lifecycle is called at the right time (see line, commit)
  • Safety checks for opening/closing modals that contain a tab view

It seems we don't really need the material plugin approach for retrieving child fragment manager since adapter always adds/attaches fragments to tabView._getFragmentManager(), so this PR uses the fragment tag to resolve the tab fragment directly and consequently the child fragment manager here.

Fixes #10165.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 24, 2026

View your CI Pipeline Execution ↗ for commit 99443e9

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 51s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-25 08:15:55 UTC

@CatchABus CatchABus marked this pull request as ready for review May 24, 2026 21:20
Copy link
Copy Markdown
Collaborator

@farfromrefug farfromrefug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good. Juste one question. You say you always add the fragment to the adapter fragment manager while the material.plugin does not. Couldn't the material plugin do the same ?

@CatchABus
Copy link
Copy Markdown
Contributor Author

CatchABus commented May 25, 2026

Seems good. Juste one question. You say you always add the fragment to the adapter fragment manager while the material.plugin does not. Couldn't the material plugin do the same ?

My comment is a bit misleading and that's not what I wanted to say.

Material plugin uses ViewPager2 with a modern fragment state adapter which makes use of activity fragment manager internally https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/viewpager2/viewpager2/src/main/java/androidx/viewpager2/adapter/FragmentStateAdapter.java#111.
On the other hand, TabView sticks to old ViewPager and an adapter class implemented on JS side. That class uses the core API to retrieve fragment manager there.
While these material fragment manager changes make total sense here, TabView may just not need this "yet".

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.

[Android][NS 8.3] Incorrect TabView behaviour

2 participants