Skip to content

bug: routing integrations don't support hash links #19365

Closed

Description

@maxtacco

Ionic version:

[x] 4.x

Current behavior:
Angular has options to enable anchor handling using the following router config:

RouterModule.forRoot(routes, {
      anchorScrolling: 'enabled',
      onSameUrlNavigation: 'reload', // required to handle clicking same anchor twice
      scrollPositionRestoration: 'enabled'
    })

These options do not work when Ionic is used.

Expected behavior:
The options should be supported or alternate solution provided.

Steps to reproduce:

  1. Create a page with anchors using routerLink with fragment directive to different sections.
  2. Try clicking on anchors.

Ionic info:

Ionic:

   Ionic CLI                     : 5.2.4 (/Users/[user]/.nvm/versions/node/v10.15.3/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.9.0
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : ios 5.0.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.5.1, (and 14 other plugins)

Utility:

   cordova-res : 0.6.0
   native-run  : 0.2.8

Activity

  1. self-assigned this
    on Feb 7, 2022
  2. averyrousseau commented on Feb 7, 2022

    @averyrousseau
    Contributor

    Thanks for the issue! It looks like this is still an issue in Ionic 6. I spun up an Angular test app with the following HTML inside an ion-content:

    <p id="testPara">test</p>
    <p>test</p>
    <p>test</p>
    <!-- more paras here -->
    <ion-button [routerLink]="['/home']" fragment="testPara">Anchor Link</ion-button>

    Clicking the button correctly changed my URL to /home#testPara, but the content didn't scroll. The behavior was the same whether I had the router config set up as described or not. I was also able to replicate this behavior in React and Vue using routerLink="#testPara".

    We'll likely need to update the routing integrations for each framework to detect a hash in the URL and call a scroll method on ion-content as needed.

    In the meantime, a possible workaround would be to use the scrollToPoint method on ion-content to manually scroll to the element with the chosen ID.

  3. changed the title [-]bug: Support for Angular's 'anchorScrolling' router option[/-] [+]bug: routing integrations don't support hash links[/+] on Feb 7, 2022
  4. removed their assignment
    on Feb 7, 2022
  5. joelmeaders commented on Dec 13, 2023

    @joelmeaders

    Just ran into this. Anyone find any good fixes?

  6. added a commit that references this issue on May 28, 2026
    a982516
  7. ShaneK commented on Jun 3, 2026

    @ShaneK
    Member

    Hey! The fix for this has been released as part of v8.8.9. Thanks for the report!

  8. ionitron-bot commented on Jul 3, 2026

    @ionitron-bot

    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.

  9. locked and limited conversation to collaborators on Jul 3, 2026
  10. added a commit that references this issue on Oct 3, 2026
    8dd4f58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions