← 输入框|github.com|刷新
Skip to content

TabView loads wrong frame #6543

Closed
Closed

Description

@lukasz-galka

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

Sample project
https://play.nativescript.org/?template=play-js&id=YD889F

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.

Activity

  1. changed the title [-]TabView loads wron frame[/-] [+]TabView loads wrong frame[/+] on Nov 11, 2018
  2. self-assigned this
    on Nov 12, 2018
  3. tsonevn commented on Nov 12, 2018

    @tsonevn
    Contributor

    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

  4. manoldonev commented on Nov 13, 2018

    @manoldonev
    Contributor

    @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

  5. self-assigned this
    on Nov 13, 2018
  6. lock commented on Nov 21, 2019

    @lock

    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.

  7. locked and limited conversation to collaborators on Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions