You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Environment
√ Component nativescript has 5.0.0 version and is up to date.
√ Component tns-core-modules has 5.0.2 version and is up to date.
√ Component tns-android has 5.0.0 version and is up to date.
× Component tns-ios is not installed.
Describe the bug
TabView loads wrong frame
To Reproduce
Change tab and see which frame is loaded
click on tab1 loads tab1, on tab2 loads tab1, on tab3 loads tab2
Expected behavior
It should load proper Frame
click on tab1 loads tab1, on tab2 loads tab2, on tab3 loads tab3
Additional context
I develop my app with core modules 4.1.1 and it worked fine. I've updated to the latest version 5.0.2 and I've noticed this issue. What is interesting it also works with core modules 5.0.0, so 5.0.2 introduced this issue.
Hi @lukasz-galka,
Thank you for the provided sample project.
I tested the case on my side and was able to recreate the issue. I will mark this as a bug, and we will investigate it further. Meanwhile, I would suggest creating a separate page for each Frame, loaded in the TabView. Example
@lukasz-galka just to clarify that the observed behavior is not a result of the tabview loading incorrect frame but the fact that frameModule.topmost() might return a different frame from what you would expect based on where in the app lifecycle it was called.
To elaborate -- on further investigation it seems this is not a bug within the core modules but a side effect of the usage of loaded event to set bindingContext, the usage of frameModule.topmost() and this change that was introduced in tns-core-modules@5.0.2 and is documented here:
Changing androidOffscreenTabLimit to 1 essentially means we are now always loading one tab to the left and right of the visible tab preemptively. Let's say you navigated to tab3, then to tab2 -- the new behavior means that the page loaded event for tab1 will be fired at this moment (even though tab1 is not visible because it is a direct neighbor of tab2. However, at this point tab2 is the visible tab and your logic in page1 that calls frameModule.topmost() will correctly return the frame for tab2.
Generally page loaded event is not the correct place to set the binding context for the page -- a better option is to use the page navigatingTo event and switching your logic to it will solve your problem.
Also, while frameModule.topmost() will work with the suggestion above, some time ago we introduced a more deterministic and straightforward API for retrieving frame references via the page.frame property that you might want to explore -- you can find more information here
Activity
[-]TabView loads wron frame[/-][+]TabView loads wrong frame[/+]tsonevn commentedon Nov 12, 2018
Hi @lukasz-galka,
Thank you for the provided sample project.
I tested the case on my side and was able to recreate the issue. I will mark this as a bug, and we will investigate it further. Meanwhile, I would suggest creating a separate page for each Frame, loaded in the TabView. Example
manoldonev commentedon Nov 13, 2018
@lukasz-galka just to clarify that the observed behavior is not a result of the tabview loading incorrect frame but the fact that frameModule.topmost() might return a different frame from what you would expect based on where in the app lifecycle it was called.
To elaborate -- on further investigation it seems this is not a bug within the core modules but a side effect of the usage of
loadedevent to set bindingContext, the usage offrameModule.topmost()and this change that was introduced in tns-core-modules@5.0.2 and is documented here:androidOffscreenTabLimitto 1 when using bottom tabs for android(fix(tab-view-android): change androidOffscreenTabLimit to 1 #6476) (371fc9b)Changing
androidOffscreenTabLimitto 1 essentially means we are now always loading one tab to the left and right of the visible tab preemptively. Let's say you navigated to tab3, then to tab2 -- the new behavior means that the pageloadedevent for tab1 will be fired at this moment (even though tab1 is not visible because it is a direct neighbor of tab2. However, at this point tab2 is the visible tab and your logic in page1 that callsframeModule.topmost()will correctly return the frame for tab2.Generally page
loadedevent is not the correct place to set the binding context for the page -- a better option is to use the pagenavigatingToevent and switching your logic to it will solve your problem.Also, while
frameModule.topmost()will work with the suggestion above, some time ago we introduced a more deterministic and straightforward API for retrieving frame references via the page.frame property that you might want to explore -- you can find more information herelock commentedon Nov 21, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.