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

[Bug]: Enter key or space bar does not call the onclick handler on Link component when used as span #33560

Open
2 tasks done
msft-mscari opened this issue Jan 6, 2025 · 2 comments · May be fixed by #33587
Open
2 tasks done

Comments

@msft-mscari
Copy link

Component

Link

Package version

9.42.0

React version

16.14.0

Environment

OS: Windows 11 10.0.22631
    CPU: (20) x64 Intel(R) Core(TM) i9-10900 CPU @ 2.80GHz
    Memory: 12.70 GB / 63.71 GB
  Browsers:
    Edge: Chromium (127.0.2651.98)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @fluentui/react-components: 9.42.0 => 9.42.0

Current Behavior

Link component when used as span (which is what is needed to make sure it wraps well). Enter key or space bar does not call the onclick handler.
https://react.fluentui.dev/?path=/docs/components-link--docs

Expected Behavior

Enter key or space bar would call the onclick handler.

Reproduction

https://stackblitz.com/edit/slflnjho?file=src%2Fexample.tsx

Steps to reproduce

Use the Link component as span.
Include a click handler.
Try Enter key or space bar to activate.

Are you reporting an Accessibility issue?

yes

Suggested severity

Urgent - No workaround and Products/sites are affected

Products/sites affected

No response

Are you willing to submit a PR to fix?

no

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@mainframev
Copy link
Contributor

mainframev commented Jan 8, 2025

hi @msft-mscari 👋🏻

It's expected behaviour with span, as if you are not using button, then there is need to handle explicitly focus and keys behaviour.

However, we already support span, which was't support until this and it adds tabIndex and role="button", but without control of the keys.

It’s possible that explicit handling for Enter and Space wasn't implemented intentionally, or perhaps it was overlooked. @khmakoto, do you recall the reasoning behind not adding this support?

@khmakoto
Copy link
Member

khmakoto commented Jan 8, 2025

@mainframev we probably overlooked it at the time, we should add it for completeness imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment