Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49083

How to programmatically click ion-segment-button?

$
0
0

I am using @ionic/angular 5.3.1.

I am seeking a way to programmatically click an ion-segment-button. I know that I can programmatically switch segments, but I want to also trigger the switching animation. (It is a use case where the user is in the wrong segment, and I want to the program to help teach the user where they want to be. The existing animation would be perfect for this.)

The problem is that the button element lies in the shadow DOM of the ion-segment-button. It can be accessed for CSS styling through the native Shadow Part[1], but don’t think I can access it programmatically to invoke its click() method.

I see that a similar issue was addressed in Ionic 4 here https://github.com/ionic-team/ionic-framework/issues/14980. There, it was implied that my goal is achievable by “using the ‘ionSelect’ event instead of ‘click’ and setting the checked property instead of clicking.” But when I look at the docs for ion-segment and ion-segment-button, I do not see any reference to either the IonSelect event, or the checked property.

Thank you, in advance, for your help.

[1] https://ionicframework.com/docs/api/segment-button#css-shadow-parts

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>