Skip to content

Fixed tab index order for tab press #755

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/discussions/learners/learner/LearnerFilterBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const ActionItem = React.memo(({
style={{ cursor: 'pointer' }}
aria-checked={value === selected}
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={value === selected ? '0' : '-1'}
tabIndex={'0'}
Copy link
Contributor

Choose a reason for hiding this comment

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

I checked the git blame and it looks like this line was added for #483

Can you confirm the issue that PR was fixing is still fixed with this change?

Choose a reason for hiding this comment

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

Yes, I’ve verified that the issue addressed in PR #483 is still resolved with the current change.
Thanks @brian-smith-tcril for pointing it out and for your thorough review!

Choose a reason for hiding this comment

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

You should not have a tabindex on a Label, because it is a non-interactive role. This will throw a new error in automated testing.

>
<Icon src={Check} className={classNames('text-success mr-2', { invisible: value !== selected })} />
<Form.Radio id={id} className="sr-only sr-only-focusable" value={value} tabIndex="0">
<Form.Radio id={id} className="sr-only sr-only-focusable" value={value} tabIndex="-1">

Choose a reason for hiding this comment

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

You should not have a tabindex on a input type="radio". The radiogroup will take focus as a single tab stop, and the selection within the group may be changed via arrow keys (assuming all items have the same name attribute ).

Choose a reason for hiding this comment

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

If you want to wrap a label with an icon over a sr-only input which will take focus (which is not the technique used by the Paragon radio buttons and checkboxes, btw), you can use css::focuswithin on the wrapping Label. to change the visible focus styling.

{label}
</Form.Radio>
<span aria-hidden className="text-truncate">
Expand Down
4 changes: 2 additions & 2 deletions src/discussions/posts/post-filter-bar/PostFilterBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export const ActionItem = React.memo(({
style={{ cursor: 'pointer' }}
aria-checked={value === selected}

Choose a reason for hiding this comment

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

A label should never have an aria-checked attribute. The Form.Radio should have a regular checked value when appropriate.

// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={value === selected ? '0' : '-1'}
tabIndex={'0'}
>
<Icon src={Check} className={classNames('text-success dropdown-icon-dimensions', { invisible: value !== selected })} />
<Form.Radio id={id} className="sr-only sr-only-focusable" value={value} tabIndex="0">
<Form.Radio id={id} className="sr-only sr-only-focusable" value={value} tabIndex="-1">
{label}
</Form.Radio>
<span aria-hidden className="text-truncate">
Expand Down