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

[core] feat: make progress indicators accessible #4821

Merged
merged 3 commits into from
Jul 28, 2021
Merged
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
11 changes: 9 additions & 2 deletions packages/core/src/components/progress-bar/progressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,18 @@ export class ProgressBar extends AbstractPureComponent2<ProgressBarProps> {
{ [Classes.PROGRESS_NO_ANIMATION]: !animate, [Classes.PROGRESS_NO_STRIPES]: !stripes },
className,
);
const percent = value == null ? undefined : 100 * clamp(value, 0, 1);
// don't set width if value is null (rely on default CSS value)
const width = value == null ? undefined : 100 * clamp(value, 0, 1) + "%";
const width = percent == null ? undefined : percent + "%";

return (
<div className={classes}>
<div
aria-valuemax={100}
aria-valuemin={0}
aria-valuenow={percent == null ? undefined : Math.round(percent)}
className={classes}
role="progressbar"
>
<div className={Classes.PROGRESS_METER} style={{ width }} />
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/components/spinner/spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ export class Spinner extends AbstractPureComponent2<SpinnerProps> {
// - SPINNER_ANIMATION isolates svg from parent display and is always centered inside root element.
return React.createElement(
tagName,
{ className: classes },
{
className: classes,
role: "progressbar",
},
React.createElement(
tagName,
{ className: Classes.SPINNER_ANIMATION },
Expand Down