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

Improve keyboard accessibility of the codecard component #10405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

microbit-robert
Copy link
Contributor

This affects code cards on the experiments page. At the moment, it is not possible to trigger the feedback link of these cards via keyboard, this action simple toggles the experiment on and off. This PR addresses this and also improves the appearance of the focus-visible outline around the "Beta Editor" card.

@microbit-matt-hillsdon

@@ -95,9 +102,18 @@ export class CodeCardView extends data.Component<CodeCardProps, CodeCardState> {
const ariaLabel = card.ariaLabel || card.title || card.shortName || name;

const style = card.style || "card"
const cardDiv = <div className={`ui ${style} ${color} ${card.onClick ? "link" : ''} ${className ? className : ''}`}
role={card.role} aria-selected={card.role === "option" ? "true" : undefined} aria-label={ariaLabel} title={card.title}
onClick={clickHandler} tabIndex={card.onClick ? card.tabIndex || 0 : null} onKeyDown={card.onClick ? fireClickOnEnter : null}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fireClickOnEnter does the wrong thing here when using "Enter" or "Space" while the "Feedback" anchor tag is focussed. It prevents the default behaviour, then triggers click on this element instead of the anchor tag from which the original event was triggered, causing the experiment to toggle on/off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant