-
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
fix(angular): remove the tabindex set by routerLink from Ionic components #29744
Merged
Conversation
This file contains 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
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
packages/angular/common/src/directives/navigation/router-link-delegate.ts
Show resolved
Hide resolved
packages/angular/common/src/directives/navigation/router-link-delegate.ts
Show resolved
Hide resolved
packages/angular/common/src/directives/navigation/router-link-delegate.ts
Show resolved
Hide resolved
packages/angular/common/src/directives/navigation/router-link-delegate.ts
Show resolved
Hide resolved
thetaPC
approved these changes
Aug 7, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This was referenced Sep 21, 2024
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
routerLink
directive 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 withrouterLink
using theTab
key, you need to press theTab
key 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
RouterLinkDelegateDirective
to check if the element usingrouterLink
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
, orion-tab-button
. If so, it removes thetabindex
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:
Note
I did not include the
ion-router-link
component in the list to removetabindex
because 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