Skip to content

[Bug]: V9 Card: when card is focusable (focusMode='tab-only'), onKeyDown events for pressing Enter are not executed #31505

Closed

Description

Library

React Components / v9 (@fluentui/react-components)

System Info

System:
    OS: Windows 10 10.0.22631
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1265U
    Memory: 14.86 GB / 31.83 GB
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.22621.3527

Are you reporting Accessibility issue?

yes

Reproduction

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

Bug Description

tab-only focusMode replicates the no-tab "Press Enter to focus content" behaviour but it should not (because it's already covered by pressing "tab"), and this in turn disallows applying the "onClick" behaviour to the "Enter key" event (which breaks a11y, because the onClick and "press Enter" behaviours should match).

Actual Behavior

When a card is using focusMode='tab-only' and it has an event handler onKeyDown that handles Enter logic, this logic is not executed. In the example on the repro provided, when the Card is focused, onKeyDown should be executed by pressing Enter, it instead navigates to the action button.

Expected Behavior

The onKeyDown event provided in the Card component should be executed. Example scenario: the card itself might navigate on Enter and tabbing might navigation into, across and out of the Card containers by using focusMode="tab-only".

Logs

No response

Requested priority

Normal

Products/sites affected

Microsoft Loop

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.

Activity

  1. changed the title [-][Bug]: [/-] [+][Bug]: V9 Card: when card is focusable, onKeyDown events set in the props are ignored[/+] on May 29, 2024
  2. katiearriagam commented on May 31, 2024

    @katiearriagam
    ContributorAuthor

    Related to: #31529

  3. changed the title [-][Bug]: V9 Card: when card is focusable, onKeyDown events set in the props are ignored[/-] [+][Bug]: V9 Card: when card is focusable (focusMode='tab-only'), onKeyDown events for pressing Enter are not executed[/+] on May 31, 2024
  4. kolaps33 commented on Jun 13, 2024

    @kolaps33
    Contributor

    I have experience the same behavior... would be nice to fix it...

  5. smhigley commented on Aug 1, 2024

    @smhigley
    Contributor

    This would need to be a tabster change, though I agree that for tab-only enter should not do anything.

    In the meantime, on the Fluent side, would it work to do <Card focusMode="off" tabIndex="0" onKeyDown={etc}>? That will give you something similar to the tab-only behavior, but without Enter moving you into the card. After the changes in #32200, you should be able to do focusMode=off on an interactive card and have it be respected.

  6. marcosmoura commented on Sep 12, 2024

    @marcosmoura
    Contributor

    Katie Arriaga M. (@katiearriagam)
    Can you check if the change Sarah Higley (@smhigley) proposed would work for your case?
    If not, we can evaluate other options here.

  7. katiearriagam commented on Sep 22, 2024

    @katiearriagam
    ContributorAuthor

    Looks like the workaround does work well enough for our use case - thanks!

  8. marcosmoura commented on Sep 24, 2024

    @marcosmoura
    Contributor

    In this case, I'll close this issue. In case there is anything needed in the future, we can reopen. 🙂

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions