Title: routerLink directive always makes element focusable · Issue #28345 · angular/angular · GitHub
Open Graph Title: routerLink directive always makes element focusable · Issue #28345 · angular/angular
X Title: routerLink directive always makes element focusable · Issue #28345 · angular/angular
Description: 🐞 bug report Affected Package @angular/router Description Issue #10895 requests that the routerLink-directive should automatically add tabindex on the target element if not already present (implemented via #13094). I understand that this...
Open Graph Description: 🐞 bug report Affected Package @angular/router Description Issue #10895 requests that the routerLink-directive should automatically add tabindex on the target element if not already present (impleme...
X Description: 🐞 bug report Affected Package @angular/router Description Issue #10895 requests that the routerLink-directive should automatically add tabindex on the target element if not already present (impleme...
Opengraph URL: https://github.com/angular/angular/issues/28345
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"routerLink directive always makes element focusable","articleBody":"# 🐞 bug report\r\n\r\n### Affected Package\r\n@angular/router\r\n\r\n### Description\r\n\r\nIssue https://github.com/angular/angular/issues/10895 requests that the `routerLink`-directive should automatically add `tabindex` on the target element if not already present (implemented via https://github.com/angular/angular/pull/13094).\r\n\r\nI understand that this behavior might be convinient in some cases, but it should still be configurable.\r\n\r\nFor example, in order to implement a custom menu widget it's a good practice that the focus always stays on the surrounding element (e.g. `\u003cnav>`) while the user selects the target menu item with the arrow keys.\r\n\r\nRight now, implementing this in a clean and straight-forward way is not possible due to the feature implemented in the issue above. If `\u003ca>` is used for the menu entries, the `href` injected by `routeLink` makes it focusable and even if `\u003cspan>` is used instead, `routeLink` still injects a `tabindex=0` to always make it focusable.\r\nWhen the user then clicks on a link the surrounding `\u003cnav>` element looses its focus as focus moves to the link that has been clicked instead. Even setting `tabindex=\"-1\"` only prevents tabbing to the link but still allows focus via mouse click.\r\n\r\nThere should either be a configuration parameter to prevent setting of `tabindex` or the feature should be reverted as `tabindex` can always be configured manually if necessary.\r\n\r\n## 🔬 Minimal Reproduction\r\n\u003c!--\r\nPlease create and share minimal reproduction of the issue starting with this template: https://stackblitz.com/fork/angular-issue-repro2\r\n-->\r\nhttps://stackblitz.com/edit/angular-issue-repro2-qudebd\r\n\r\n```html\r\n\u003cnav tabindex=\"0\">\r\n \u003col>\r\n \u003cli>\r\n \u003c!-- becomes focusable because of href attribute -->\r\n \u003ca routerLink=\"bikes\" routerLinkActive=\"active\">Bikes\u003c/a>\r\n \u003c/li>\r\n \u003cli>\r\n \u003c!-- becomes focusable because of tabindex attribute -->\r\n \u003cspan routerLink=\"cars\" routerLinkActive=\"active\">Cars\u003c/span>\r\n \u003c/li>\r\n \u003c/ol>\r\n\u003c/nav>\r\n```\r\n\u003c!--\r\nIf StackBlitz is not suitable for reproduction of your issue, please create a minimal GitHub repository with the reproduction of the issue. Share the link to the repo below along with step-by-step instructions to reproduce the problem, as well as expected and actual behavior.\r\n\r\nIssues that don't have enough info and can't be reproduced will be closed.\r\n\r\nYou can read more about issue submission guidelines here: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-submitting-an-issue\r\n-->\r\n\r\n## 🌍 Your Environment\r\n\r\n**Angular Version:**\r\n\u003cpre>\u003ccode>\r\nAngular CLI: 6.2.9\r\nNode: 8.11.3\r\nOS: darwin x64\r\nAngular: 6.1.10\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... http, language-service, platform-browser\r\n... platform-browser-dynamic, router\r\n\r\nPackage Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect 0.8.9\r\n@angular-devkit/build-angular 0.8.9\r\n@angular-devkit/build-optimizer 0.8.9\r\n@angular-devkit/build-webpack 0.8.9\r\n@angular-devkit/core 0.8.9\r\n@angular-devkit/schematics 0.8.9\r\n@angular/cli 6.2.9\r\n@ngtools/webpack 6.2.9\r\n@schematics/angular 0.8.9\r\n@schematics/update 0.8.9\r\nrxjs 6.3.3\r\ntypescript 2.9.2\r\nwebpack 4.16.4\r\n\u003c/code>\u003c/pre>\r\n\r\n**Anything else relevant?**\r\n\u003c!-- ✍️Is this a browser specific issue? If so, please specify the browser and version. -->\r\nThis can be reproduced as described in Chrome v71.0.3578.98.\r\nIn Safari the focus is only lost on the second link (i.e. where `\u003cspan>` is used).\r\n\r\n","author":{"url":"https://github.com/akloeber","@type":"Person","name":"akloeber"},"datePublished":"2019-01-24T17:38:01Z","url":"https://github.com/angular/angular/issues/28345"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:72c87556-103d-e428-5de1-6dbbbb6bb79c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ADFE:1087D4:13D34A8:1A7A08F:6B012EB4 |
| html-safe-nonce | 8bc00d7123abec07f7039435d6739ec9173d8a473b05a5a68f231c0a7ebd945c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBREZFOjEwODdENDoxM0QzNEE4OjFBN0EwOEY6NkIwMTJFQjQiLCJ2aXNpdG9yX2lkIjoiMTY5MjM4MDcwMzEzMzYwOTY1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 228e6a1b3baf5a6acd86fe85e99190141d8fee921871e923eb812e1b148f95aa |
| hovercard-subject-tag | issue:402820115 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/28345/issue_layout |
| twitter:image | https://opengraph.githubassets.com/02a6302d73c13d5d2aabbdf8d80e43e4da950632fae78a9a8b5c80ec913f2dbd/angular/angular/issues/28345 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/02a6302d73c13d5d2aabbdf8d80e43e4da950632fae78a9a8b5c80ec913f2dbd/angular/angular/issues/28345 |
| og:image:alt | 🐞 bug report Affected Package @angular/router Description Issue #10895 requests that the routerLink-directive should automatically add tabindex on the target element if not already present (impleme... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | akloeber |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width