ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.02k stars 13.51k forks source link

bug: ionTabsWillChange fires after tab has changed. #18900

Closed masimplo closed 2 years ago

masimplo commented 5 years ago

Bug Report

Ionic version:

[x] 4.x

Current behavior:

Calling a function on ionTabsWillChange event emission. Adding a breakpoint on that function is hit after the tab is changed. From the code it seams that ionTabsWillChange and ionTabsDidChange are fired together:

  onPageSelected(detail: StackEvent) {
    const stackId = detail.enteringView.stackId;
    if (detail.tabSwitch && stackId !== undefined) {
      if (this.tabBar) {
        this.tabBar.selectedTab = stackId;
      }
      this.ionTabsWillChange.emit({ tab: stackId });
      this.ionTabsDidChange.emit({ tab: stackId });
    }
  }

https://github.com/ionic-team/ionic/blob/6929bb817cff5e4ac3eb266e7aca45173c361789/angular/src/directives/navigation/ion-tabs.ts#L64

Expected behavior:

ionTabsWillChange should fire right before the tab is changed.

Steps to reproduce:

Related code:

insert short code snippets here

Other information:

Ionic info:

insert the output from ionic info here
averyjohnston commented 2 years ago

This has (at last!) been resolved via https://github.com/ionic-team/ionic-framework/pull/24910, and the fix will be available in a future release of Ionic 👍

ionitron-bot[bot] commented 2 years ago

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.