fix(angular): remove the tabindex set by routerLink from Ionic components - #29744
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
sean-perkins
approved these changes
Aug 2, 2024
thetaPC
requested changes
Aug 5, 2024
This was referenced Sep 21, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: resolves #20632
What is the current behavior?
When using the
routerLinkdirective in Angular, it automatically addstabindex="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 withrouterLinkusing theTabkey, you need to press theTabkey twice to move to the next item. This problem is illustrated in the following demo:Related Angular issue: angular/angular#28345
What is the new behavior?
Updated our
RouterLinkDelegateDirectiveto check if the element usingrouterLinkis 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, orion-tab-button. If so, it removes thetabindexattribute 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:
Note
I did not include the
ion-router-linkcomponent in the list to removetabindexbecause the router link documentation does not recommend using it with Angular:Does this introduce a breaking change?
Other information
Dev build:
8.2.7-dev.11722448707.1e8c66e6