Skip to content

Observable boolean initially set to true not working on iOS #5694

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

Closed
NickIliev opened this issue Apr 17, 2018 · 3 comments · Fixed by #5724
Closed

Observable boolean initially set to true not working on iOS #5694

NickIliev opened this issue Apr 17, 2018 · 3 comments · Fixed by #5724
Assignees
Labels
Milestone

Comments

@NickIliev
Copy link
Contributor

From @felix-idf on April 16, 2018 14:46

Did you verify this is a real problem by searching the NativeScript Forum?

Yes

Tell us about the problem

I wanted to take advantage of the latest release of nativescript 4.0 and nativescript-ui-sidedrawer, by sharing one single sidedrawer as the root view of the whole app. Everything seems to work as expected on Android, but I notice some issues on iOS.
Our SideDrawer should have different content for logged-in users and not logged-in users, so we bind the content of our drawer to an observable and by switching the "IsLoggedIn" property there, the content of the drawer should change. This scenario worked on previous versions of NativeScript and the SideDrawer component (where we had to define the Drawer on every single page).

Which platform(s) does your issue occur on?

iOS

Please provide the following version numbers that your issue occurs with:

  • Progress NativeScript UI version: 4.0.0
  • CLI: (run tns --version to fetch it): 4.0.0
  • Cross-platform modules: 4.0.0
  • Runtime(s): 4.0.1

Please tell us how to recreate the issue in as much detail as possible.

  1. Start the application
  2. Tap the first button to open the drawer: there are just 2 options visible in the drawer
  3. Close Drawer
  4. Tap the second button to switch the state of the "isLoggedIn" property of the bindingContext of the drawer
  5. Tap the first button again to open the drawer and now there are 4 options visible on Android, but still only 2 options on iOS, which is not the expected behaviour
    sidedrawer_issue_4_0

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

Sample project can be found here:
NSIssues4.zip

Copied from original issue: ProgressNS/nativescript-ui-feedback#623

@NickIliev
Copy link
Contributor Author

From @VladimirAmiorkov on April 16, 2018 19:4

Hi @felix-idf ,

Thank you for reporting this to us. I will take a closer look and see what may be causing this behavior on iOS. I will update you here once I have more information to share.

@NickIliev
Copy link
Contributor Author

From @VladimirAmiorkov on April 17, 2018 13:22

Hi @felix-idf ,

I managed to observe the described issue on iOS and it looks to be caused by the value (false) set to the isLoggedIn of the vmTest object. If that value is set to true initially the observed issue is not longer reproducible. In order to workaround this issue you can set the isLoggedIn to true and immediately after that in a setTimeout set it to the desired initial value of false, like so:

var observableModule = require("data/observable");
var vmTest = observableModule.fromObject({
    isLoggedIn: true,
    loggedInNick: "Tester"
});

setTimeout(() => {
    vmTest.set("isLoggedIn", false);
})

exports.vmTest = vmTest;

Also note that while having expressions in bindings like you have for the visibility in the app-root.xml make sure to set it like this, more details can be found here:
visibility="{{ isLoggedIn, isLoggedIn ? 'visible' : 'collapse' }}"

I think this issue should be mover to the main NativeScript repository as it is caused by the data/observable module. @NickIliev What do you think, can we move this to https://github.com/NativeScript/NativeScript/issues ?

@NickIliev NickIliev changed the title RadSideDrawer iOS issues when changing bindingContext of drawerContent Observable boolean set to TRUE not working on iOS Apr 17, 2018
@NickIliev NickIliev changed the title Observable boolean set to TRUE not working on iOS Observable boolean initially set to true not working on iOS Apr 18, 2018
@vakrilov vakrilov added this to the 4.1 milestone Apr 23, 2018
@ghost ghost removed bug in progress labels Apr 23, 2018
@lock
Copy link

lock bot commented Aug 27, 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.

@lock lock bot locked and limited conversation to collaborators Aug 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants