Skip to content

bug: ion-segment (ionChange) trigger is not consistent on start #19204

@ben-kn-app

Description

@ben-kn-app

Bug Report

Ionic version:

[x] 4.7.1

Current behavior:

ion-segment (ionChange) trigger is not consistent when opening multiple pages containing ion-segment.

Imagine 2 tab pages, named Tab2 and Tab3 for convenience, both with ion-segment. If you open the first one Tab2 the ionChange of the ion-segment is not triggered (as expected), if you afterwards (without restarting the app) open the Tab3 page its ionChange is fired (Unexpected).

This also works vice-versa. Restarting the app and opening first Tab3 will not fire the ionChange of the ion-segment, afterwards opening Tab2 will fire ionChange which is unexpected.

Expected behavior:

One would expect that all pages with ion-segment wouldn't fire its ionChange upon opening. Regardless of which page was opened first.

Steps to reproduce:
Using the simple tabs starter. I've been able to reproduce this problem. By modifying Tab2 and Tab3 to include an ion-segment with (ionChange). Both do a simple console.log output of the event.

  1. Open the app https://ionic-v4-angular-tabs-jrynng.stackblitz.io
  2. Open the console
  3. Click on Tab2 and verify that no ionChange event is shown in console
  4. Click on Tab3 and verify that an ionChange event is shown in console (Unexpected).
  5. Restart app and open console
  6. Click on Tab3 and verify that no ionChange event is shown in console
  7. lick on Tab2 and verify that an ionChange event is show nin console (Unexpected).

Code: https://stackblitz.com/edit/ionic-v4-angular-tabs-jrynng

Additional Info
This bug wasn't present in ionic/[email protected] My best guess is that something changed to the ion-segment/(ionChange) behavior between version 4.3.0 and 4.7.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions