question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: ion-segment and ion-segment-button href not working

See original GitHub issue

Bug Report

Ionic version: [x] 5.x

Current behavior: when using the ion-segments with href navigation doesn’t work. as a workaround, I wrapped ion-segment-button with <a [routerLink] = “…” and used [routerLinkActive]= “…” in ion-segment-button. This worked fine in V 4 but is now broken I need the links for SEO so (ionChaneg) won’t do the trick

Expected behavior: should be able to navigate and determine active segment based on url e.g. https://cubesolver.app/tabs/guide/advanced/pll/f should go to the right page and mark “Advanced”, “PLL”, and “f” segments as active (the link above is to a working V4

Steps to reproduce: see code example below…

Related code:

<ion-segment [(ngModel)]="segment"  >
  <a [routerLink]="'/tabs/guide/using'" >
    <ion-segment-button  value="using" [routerLinkActive]="'segment-button-checked segment-activated'" >
      <div class="container icon-container">
        <div class="sprite-png sprite-png-custom"></div>
      </div>
      <div class="container text-container">Using</div>
    </ion-segment-button>
  </a>

  <a [routerLink]="'/tabs/guide/solving'">
    <ion-segment-button value="solving"   [routerLinkActive]="'segment-button-checked segment-activated'" >
      <div class="container icon-container">
        <div class="sprite-png sprite-png-solve"></div>
      </div>
      <div class="container text-container">Solving</div>
    </ion-segment-button>
  </a>
  <a [routerLink]="'/tabs/guide/advanced'">
    <ion-segment-button value="f2l"   [routerLinkActive]="'segment-button-checked segment-activated'">
      <div class="container icon-container">
        <div class="sprite-png sprite-png-advanced"></div>
      </div>
      <div class="container text-container">Advanced</div>
    </ion-segment-button>
  </a>
</ion-segment>
insert short code snippets here

Other information:

Ionic info:

insert the output from ionic info here

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
yarivgdidicommented, Feb 11, 2020

Hi Congrats on the new release 😃 After upgrading to 5.0 and minor changes to my code, things looks better.

By other glitches, I meant unexpected behavior where I could’t put my finger on what I’ve did different.

To sum things up: For the reproduction I’ve made 3 slightly different implementation of segments with Icon in the button tab one - as in documentation tab two - button wrapped with a link (I need this for SEO) tab three - button wrapped with like in tab two but navigation is done from JS on iconChange event

Most issues where when clicking on the inner div (the icon) in mobile simulation mode

Tab three seems to work OK now - main issues were propagation of inner div event causing to bad routing are now solved

Tab two - navigation doesn’t work in mobile simulation (as did in Ionic 4 and do in desktop mode)

Tab one - because it is not wrapped with link, when refreshing the page - state is not preserved

Thanks again for the effort I feel safe to upgrade now

Yariv

0reactions
ionitron-bot[bot]commented, Mar 20, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: ion-segment and ion-segment-button href not working ...
Current behavior: when using the ion-segments with href navigation doesn't work. as a workaround, I wrapped ion-segment-button with <a [ ...
Read more >
Ion-slides not working with ion-segment after update on ionic5
When I change the view via tabbed menu, it is over. I am not able to change the slides. The view is updating,...
Read more >
div *ngIf="is_auto===false" is not showing - Stack Overflow
I have imported Browser Module and Common Module. UPDATE. The variable is cast as a boolean, but ion-segment keeps getting away with converting ......
Read more >
Ionic 5 - 12 Ion-Segment - YouTube
Segments display a group of related buttons, sometimes known as segmented controls, in a horizontal row.
Read more >
Ionic 4.5 Segment Button Bug - CodePen
Insecure Resource. The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found