Skip to content
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

[Tabs] Left/Right Arrow keyboard shortcuts consume Alt+Left/Right Arrow browser shortcuts for Back/Forward #45308

Open
Dazbii opened this issue Feb 14, 2025 · 1 comment · May be fixed by #45345
Assignees
Labels
bug 🐛 Something doesn't work component: tabs This is the name of the generic UI component, not the React module!

Comments

@Dazbii
Copy link

Dazbii commented Feb 14, 2025

Steps to reproduce

Steps:

  1. Open this link to live example: https://codesandbox.io/p/sandbox/xgl5m2 (Not in a new tab, ensure that your browser has history so that the back button would work)
  2. Focus the tabs by clicking on one of them
  3. Press Alt+{Left Arrow}

Current behavior

In some environments nothing seems to happen. Though most will move the focus between tabs

Expected behavior

Your browser should navigate to the previous page, as if you clicked the "Back" button on your browser.

Context

In Chrome, Firefox, and Edge, Alt+{Left Arrow} and Alt+{Right Arrow} are shortcuts for the browser Back and Forward buttons, respectively. The Tabs components have arrow key shortcuts to navigate between tabs, however this seems to consume all left and right arrow key inputs for horizontal tabs, regardless of if modifiers are held or not. And so the browser will not respond to Alt+{Left Arrow} and Alt+{Right Arrow} shortcuts while a tab component is in focus.

I believe that this could present accessibility concerns and the component should not consume arrow key inputs while the alt key is being held.

Your environment

npx @mui/envinfo
  System:
    OS: Linux 5.15 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
  Binaries:
    Node: 22.11.0 - /opt/node/bin/node
    npm: 10.9.0 - /opt/node/bin/npm
    pnpm: 10.2.1 - /opt/node/bin/pnpm
  Browsers:
    Chrome: Not Found
  npmPackages:
    @emotion/react: 11.14.0 => 11.14.0
    @emotion/styled: 11.14.0 => 11.14.0
    @mui/material: 6.4.4 => 6.4.4
    @types/react: 18.2.38 => 18.2.38
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    typescript: 4.4.4 => 4.4.4
Above is the environment in WSL, I connected to the server through browsers running in Windows 11 and confirmed the issue using:
  • Chrome 133.0.6943.99
  • Firefox 128.7.0esr
  • Edge 133.0.3065.59

Search keywords: tab tabs tablist tabcontext alt arrowkeys shortcut back forward accessibility

@Dazbii Dazbii added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 14, 2025
@zannager zannager added the component: tabs This is the name of the generic UI component, not the React module! label Feb 17, 2025
@mushfiqbh
Copy link

Hi @DiegoAndai, I've opened a PR to address this issue: #45345

Changes:

  • The Tabs component now ignores Alt+Left/Right Arrow key events, allowing the browser's default Back/Forward navigation to work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: tabs This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants