ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

fix(angular RouterLinkDelegateDirective): Make routerLink respect target and keyboard modifiers

Open j-oppenhuis opened this issue 1 year ago • 3 comments
trafficstars

Issue number: resolves #26394


What is the current behavior?

This fixes using routerLink in combination with a target different than _self. It also fixes a bug where CTRL + click or shift + click does not work like expected in combination with routerLink in Angular.

What is the new behavior?

When using a target other than _self and keyboard modifiers we are now stopping execution of navigating by routeDirection. This is not needed because the app will reload either way.

Does this introduce a breaking change?

  • [ ] Yes
  • [x] No

Other information

j-oppenhuis avatar Feb 05 '24 14:02 j-oppenhuis

Thank you for your feedback. I understand that it is more complex than my initial idea. Instead of changing routerLink functionality, we should probably change the openURL function. Am I correct? If that is the case than we should indeed also pass in the operating system and the target. But is that a good solution?

j-oppenhuis avatar Feb 08 '24 10:02 j-oppenhuis

I have looked into the code and I think my suggestion is incorrect. But it seems we are not able to prevent the button or item navigation by using stoppropagation. The only thing I can think of is adding a routerLink prop to the button and item components. Then we could make a distinction between desktop and mobile. When the current OS is desktop, the anchor could handle navigation. Otherwise, we could use openURL like we use now. Is that something that could work?

j-oppenhuis avatar Feb 08 '24 12:02 j-oppenhuis

We've checked out the problem, and it's a tough one. But because we're short on time, our team can't really dig into it right now. However, we're up for bouncing around ideas together. We might not have all the answers, but we'll do what we can to help out.

I agree that passing an operating system is not the way to go. We want ion-button to not have strict checks like what OS the user has.

thetaPC avatar Apr 01 '24 18:04 thetaPC