Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: routerlink with null throws error in angular 13 #24586

Closed
4 of 6 tasks
marcovmun opened this issue Jan 17, 2022 · 2 comments
Closed
4 of 6 tasks

bug: routerlink with null throws error in angular 13 #24586

marcovmun opened this issue Jan 17, 2022 · 2 comments
Labels
package: angular @ionic/angular package type: bug a confirmed bug report

Comments

@marcovmun
Copy link

marcovmun commented Jan 17, 2022

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

If I use routerLink with value null, I get console error.

<ion-item [routerLink]="null"></ion-item>

Error

core.mjs:6449 
        
       ERROR TypeError: Cannot read properties of null (reading 'root')
    at DefaultUrlSerializer.serialize (router.mjs:878:51)
    at Router.serializeUrl (router.mjs:4757:35)
    at RouterLinkDelegateDirective.updateTargetUrlAndHref (ionic-angular.js:3764:79)
    at RouterLinkDelegateDirective.ngOnInit (ionic-angular.js:3752:14)
    at callHook (core.mjs:2518:1)
    at callHooks (core.mjs:2487:1)
    at executeInitAndCheckHooks (core.mjs:2438:1)
    at selectIndexInternal (core.mjs:8368:1)
    at ɵɵadvance (core.mjs:8351:1)

I think it has something to do with:

You can now disable the navigation of a routerLink by passing undefined and null. Previously the routerLink directive used to accept these two values as equivalent to an empty string.

https://update.angular.io/?l=3&v=12.0-13.0

Expected Behavior

No error is visible in console and routerlink is disabled.

Steps to Reproduce

  1. Use Ionic 5.0.2 and angular 13
  2. add view with [routerLink]="null" in an element
  3. Run project and look in console.

Code Reproduction URL

No response

Ionic Info

No response

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Jan 17, 2022
@sean-perkins sean-perkins self-assigned this Jan 18, 2022
@sean-perkins
Copy link
Contributor

@marcovmun thanks for reporting this. I don't believe we've updated our internal RouterLinkDelegate to support that new feature change in v13 of Angular.

I'll need to look into all aspects of what assigning null to the routerLink includes, so that we have alignment with the expected implementation.

@ionitron-bot
Copy link

ionitron-bot bot commented Feb 23, 2022

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: angular @ionic/angular package type: bug a confirmed bug report
Projects
None yet
Development

No branches or pull requests

2 participants