You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: V9 Card: when card is focusable (focusMode='tab-only'), onKeyDown events for pressing Enter are not executed #31505
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.
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
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.
Activity
[-][Bug]: [/-][+][Bug]: V9 Card: when card is focusable, onKeyDown events set in the props are ignored[/+]katiearriagam commentedon May 31, 2024
Related to: #31529
[-][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[/+]kolaps33 commentedon Jun 13, 2024
I have experience the same behavior... would be nice to fix it...
smhigley commentedon Aug 1, 2024
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 thetab-onlybehavior, but without Enter moving you into the card. After the changes in #32200, you should be able to dofocusMode=offon an interactive card and have it be respected.marcosmoura commentedon Sep 12, 2024
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.
katiearriagam commentedon Sep 22, 2024
Looks like the workaround does work well enough for our use case - thanks!
marcosmoura commentedon Sep 24, 2024
In this case, I'll close this issue. In case there is anything needed in the future, we can reopen. 🙂