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

ProgressBar: Add default tabIndex to make focusable #53383

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- `ProgressBar`: Use the theme system accent for indicator color ([#53347](https://github.com/WordPress/gutenberg/pull/53347)).
- `ProgressBar`: Use gray 300 for track color ([#53349](https://github.com/WordPress/gutenberg/pull/53349)).
- `Modal`: add `headerActions` prop to render buttons in the header. ([#53328](https://github.com/WordPress/gutenberg/pull/53328)).
- `ProgressBar`: Add default `tabIndex` to make focusable ([#53383](https://github.com/WordPress/gutenberg/pull/53383)).

### Bug Fix

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/progress-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function UnforwardedProgressBar(
value={ value }
aria-label={ __( 'Loading …' ) }
ref={ ref }
tabIndex={ 0 }
{ ...progressProps }
/>
</ProgressBarStyled.Track>
Expand Down
13 changes: 13 additions & 0 deletions packages/components/src/progress-bar/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

/**
* Internal dependencies
Expand Down Expand Up @@ -76,4 +77,16 @@ describe( 'ProgressBar', () => {
);
expect( screen.getByRole( 'progressbar' ) ).toHaveStyle( style );
} );

it( 'should be able to focus the underlying `progress` element', async () => {
const user = userEvent.setup();

render( <ProgressBar /> );

expect( screen.getByRole( 'progressbar' ) ).not.toHaveFocus();

await user.tab();

expect( screen.getByRole( 'progressbar' ) ).toHaveFocus();
} );
} );