-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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: ion-button with [routerLink] will display a border if being activated #20632
bug: ion-button with [routerLink] will display a border if being activated #20632
Comments
Thanks for the issue! This is actually an issue due to Angular adding ion-button:focus {
outline: none;
} However, the real problem is that by adding the I left a comment on an issue on Angular's repo about this: angular/angular#28345 (comment) You should be able to work around this issue by adding |
Has there been any progress on this issue? Or has angular ignored it for over 4 years? |
…ents (#29744) Issue number: resolves #20632 --------- ## What is the current behavior? When using the `routerLink` directive in Angular, it automatically adds `tabindex="0"` to the element. This creates issues with Ionic components that render native button or anchor elements, as they have their own focus management. As a result, when navigating between list items with `routerLink` using the `Tab` key, you need to press the `Tab` key twice to move to the next item. This problem is illustrated in the following demo: [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/angular-blfa7h?file=src%2Fapp%2Fexample.component.html) Related Angular issue: angular/angular#28345 ## What is the new behavior? Updated our `RouterLinkDelegateDirective` to check if the element using `routerLink` is one of the following Ionic components: `ion-back-button`, `ion-breadcrumb`, `ion-button`, `ion-card`, `ion-fab-button`, `ion-item`, `ion-item-option`, `ion-menu-button`, `ion-segment-button`, or `ion-tab-button`. If so, it removes the `tabindex` attribute from the element. This allows these Ionic components to let the native button or anchor element handle the focus. This solution is demonstrated in the following demo: [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/angular-blfa7h-svmguh?file=src%2Fapp%2Fexample.component.html) > [!NOTE] > I did not include the `ion-router-link` component in the list to remove `tabindex` because [the router link documentation](https://ionicframework.com/docs/api/router-link) does not recommend using it with Angular: >> Note: this component should only be used with vanilla and Stencil JavaScript projects. For Angular projects, use an `<a>` and `routerLink` with the Angular router. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information Dev build: `8.2.7-dev.11722448707.1e8c66e6`
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. |
Bug Report
Ionic version:
[x] 4.11.9
Current behavior:
When activating an
<ion-button>
element with a[routerLink]
directive being set, the button will display show a border.Expected behavior:
No border should be displayed when a button gets activated.
Steps to reproduce:
ion-button
like below.Related code:
https://stackblitz.com/edit/ionic-v4-angular-tabs-9a3req
Other information:
I'm not sure whether buttons are supposed to work like this, but this does not happen with a
href
being set.I would only expect such behaviour in a real browser app, where anchors are being colored accordingly - but not within a Hybrid App on iOS :)
Ionic info:
The text was updated successfully, but these errors were encountered: