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

Changing detect stop works when handle a tab click event. #9811

Closed
netsesame2 opened this issue Dec 28, 2016 · 9 comments
Closed

Changing detect stop works when handle a tab click event. #9811

netsesame2 opened this issue Dec 28, 2016 · 9 comments
Milestone

Comments

@netsesame2
Copy link

netsesame2 commented Dec 28, 2016

Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Your system information:

ordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 0.0.47
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v4.3.1
Xcode version: Not installed

Current behavior:

In an ionic's tabs based app, if we handle a button click from a tab button, change some states, ionic's changing detecting mechanism for the current page will stop working. Only thing we can do is exist and re-enter the view.

Expected behavior:

We hope it will be that, by clicking a tab button, change some states, the states will be updated in the binding views.

Steps to reproduce:

  1. start a new project demo with default tabs template.
  2. add a button tab in tabs.html as:

<ion-tab tabTitle="" tabIcon="camera" (ionSelect)="takePhoto()"></ion-tab>

  1. Inject events into tabs.ts, and add a test method in tabs.ts:

export class TabsPage {
...
constructor(private events: Events) {}

takePhoto() {
this.events.publish("data:changed");
}
}

  1. Inject Events into home.ts, and subscribe to above event:

export class HomePage {
datatest: string = "old";

constructor(public navCtrl: NavController, public events: Events) {
events.subscribe("data:changed", this.change.bind(this));
}

change() {
console.log("data changed!");
this.datatest = "new!";
}
}

  1. add a variable binding to anywhere in home.html:

<button ion-button (click)="change()">TEST</button>
<label>{{datatest}}</label>

  1. click the 'camera‘ tab, watch the home page. no update is happen. while the console print the expected value.
  2. click the 'test' button on home page, no update is happen also.
  3. re-enter the home page, repeat 7, update take effect.
@jgw96 jgw96 added the v2 label Dec 28, 2016
@mhartington mhartington reopened this Jan 4, 2017
@mhartington
Copy link
Contributor

Spook too soon. Looks like you're right. Thanks for the heads up

@mhartington mhartington added this to the 2.0.0-rc.5 milestone Jan 4, 2017
@matthewfreedman
Copy link

matthewfreedman commented Jan 5, 2017

This looks like a duplicate of #9392. I am affected by the same issue.

@kelvindart
Copy link
Contributor

I believe so - if so, then @manucorporat has fixed it I believe - see: #9512 (but the rc.5 milestone was removed from #9392, so I do not know if it is destined for rc.5 or not).

@mhartington
Copy link
Contributor

Pulling down #9512 locally and applying it to my test seem to fix things!

mhartington pushed a commit that referenced this issue Jan 6, 2017
The current selected tab should NOT be deselected (i.e. detached from change detection) if the selected tab does not have a root
ie. a tab that acts as a button to open a modal, logout etc.

Lifecycle events should not be dispatched either. Right now we are dispatching willLeave/willEnter always (this is a bug).

Closes #9392. Closes #9811. Closes #9392.
@netsesame2
Copy link
Author

So, where can I get this fix?

@mhartington
Copy link
Contributor

mhartington commented Jan 7, 2017 via email

@brandyscarney
Copy link
Member

This will be in the next release, if you'd like to test it sooner please install the latest nightly:

npm install --save ionic-angular@nightly

Let us know if you see any problems. Thanks!

@netsesame2
Copy link
Author

The nightly version fix it perfectly. Thanks a lot.

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 5, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants