This bug is really hard to explain or reproduce, so I’ll try to do my best to explain it.
Sometimes, when switching in a segment, the button does NOT switch.
When it does not switch, the display is broken (it seems to stay in a intermediary state: in Android, the button is grey, instead of blue for selected, or white for unselected. in iOS, it stays white.).
The business logic is broken too. Let’s see both working and not working examples:
Initial State:
Here is the initial page, with the “25€” button selected by default:
Working example:
When touching the “50€” button, the button switches, the amounts below are updated:
NOT working example:
Here is an example with Android: when touching the “50€” button, the button does not really switch (grey color), and the amounts below are not updated:
Solving attempts:
- I thought the bug was related to a problem with the segment component, since I read lots of similar issues about it. I decided to use 4 simple buttons instead of a segment, reproducing the segment behaviour manually. But I had exactly the same problem in the end! (examples above are with classic buttons, not segments).
Some information that could help understand:
-
The bug occurs sometimes. To be more specific, let’s say the page that can bug is
B
, and two other pages that can lead toB
areA1
andA2
. It never bugs when coming fromA1
toB
and bugs sometimes when coming fromA2
toB
.
And when making it work once usingA1
page, it never bugs then. So, usingA1
page first is a way to “solve” the bug. -
The bug occurs no matter the device (desktop, smartphone) and no matter the os (android or iOS)
-
I suppose (but I could be wrong) that the problem does not come directly from a mistake in my code.
-
Some actions (like rotating my phone from portrait to landscape, or clicking another button which opens popup) temporarily solve the bug (it “finished” the last switching action, but if I switch again, clicking another button, it still won’t work).
-
Here is my ionic info:
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
@ionic/app-scripts : 2.1.4
Ionic Framework : ionic-angular 3.6.1
Node : v8.3.0
npm : 5.3.0
OS : macOS Sierra -
I had the exact same bug with an older version of Ionic (may 2017).
Feel free to ask any additional information that could help solve one of the weirdest problem I have ever had.
Thanks a lot.