Skip to content

Feat: Add a11y for loading indicators#165173

Merged
rkishan516 merged 1 commit intoflutter:masterfrom
rkishan516:a11y-loading-indicator
Nov 11, 2025
Merged

Feat: Add a11y for loading indicators#165173
rkishan516 merged 1 commit intoflutter:masterfrom
rkishan516:a11y-loading-indicator

Conversation

@rkishan516
Copy link
Contributor

Feat: Add a11y for loading indicators
fixes: #161631

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. f: material design flutter/packages/flutter/material repository. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) platform-web Web applications specifically labels Mar 14, 2025
@rkishan516 rkishan516 force-pushed the a11y-loading-indicator branch 2 times, most recently from a4da150 to f6e5619 Compare March 15, 2025 08:09
@github-actions github-actions bot added the a: tests "flutter test", flutter_test, or one of our tests label Mar 15, 2025
@dkwingsmt dkwingsmt requested a review from chunhtai March 19, 2025 18:30
static const int _kHasRequiredStateIndex = 1 << 29;
static const int _kIsRequiredIndex = 1 << 30;
static const int _kIsProgressBarIndex = 1 << 31;
static const int _kIsLoadingSpinnerIndex = 1 << 32;
Copy link
Contributor

Choose a reason for hiding this comment

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

This flag can at most fit 32 bit, so this is likely not going to work for platform that uses 32 bit int.

Also we already have progress bar and loadingspinner in https://main-api.flutter.dev/flutter/dart-ui/SemanticsRole.html
you can directly use that.

However these 2 enums are currently not wired up engine, so we will need to update the engine still

Copy link
Contributor

Choose a reason for hiding this comment

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

actually do we need these flags in this pr? it looks like they are not used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can remove these.

semanticsObject,
preferredLabelRepresentation: LabelRepresentation.ariaLabel,
) {
setAriaRole('loadingSpinner');
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no loading spiner role in web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will remove this.

return _buildIndicator(context, _controller.value, textDirection);
},
return Semantics(
role: SemanticsRole.loadingSpinner,
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not a spinner, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is. Because if value is not given, it will be in loading mode else it will be in progreessbar mode.

enabled: widget.value != null,
role: SemanticsRole.progressBar,
child: Semantics(
enabled: widget.value == null,
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably only assign progressbar or loadingspinner but not both

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At a time, it only assign one.
Because if value is not given its loadingSpinner else its progressBar.

@rkishan516 rkishan516 force-pushed the a11y-loading-indicator branch from f6e5619 to 0034f92 Compare March 20, 2025 03:27
@github-actions github-actions bot removed the a: tests "flutter test", flutter_test, or one of our tests label Mar 20, 2025
@dkwingsmt
Copy link
Contributor

Is this PR ready for another round of review? (from triage)

@chunhtai chunhtai self-requested a review April 2, 2025 18:33
@rkishan516 rkishan516 force-pushed the a11y-loading-indicator branch from 0034f92 to b7a864f Compare April 3, 2025 01:06
@rkishan516
Copy link
Contributor Author

Is this PR ready for another round of review? (from triage)

Yes @dkwingsmt.

}
}
return Semantics(
value: widget.value != null ? '${(widget.value ?? 0) * 100}%' : null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
value: widget.value != null ? '${(widget.value ?? 0) * 100}%' : null,
value: widget.value != null ? '${widget.value! * 100}%' : null,

Copy link
Contributor

Choose a reason for hiding this comment

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

also should it have the % after the number?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed this.

setAriaRole('progressbar');

// Progress indicators in Flutter use values between 0.0 and 1.0
setAttribute('aria-valuemin', "0");
Copy link
Contributor

Choose a reason for hiding this comment

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

we may need a a new property for maxValue and minValue to propergate the value range. Hardcoded to 0 and 100 may be too opinionated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add new properties maxValue and minValue.

@rkishan516 rkishan516 force-pushed the a11y-loading-indicator branch from b7a864f to 3f35fa6 Compare April 4, 2025 01:30
@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests platform-windows Building on or for Windows specifically a: desktop Running on desktop labels Apr 4, 2025
@rkishan516 rkishan516 force-pushed the a11y-loading-indicator branch 6 times, most recently from d61aae5 to 050ace5 Compare April 5, 2025 01:42
@rkishan516 rkishan516 force-pushed the a11y-loading-indicator branch from 050ace5 to cf1d583 Compare April 22, 2025 13:14
@chunhtai chunhtai self-requested a review April 22, 2025 16:54
@rkishan516 rkishan516 force-pushed the a11y-loading-indicator branch from cf1d583 to 99965e8 Compare April 23, 2025 01:09
@rkishan516 rkishan516 force-pushed the a11y-loading-indicator branch 2 times, most recently from c0881c1 to 4661a35 Compare August 18, 2025 01:57
@rkishan516
Copy link
Contributor Author

@chunhtai I checked the tests, but couldn't figure out issue. Can you please help me with this?

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@Piinks
Copy link
Contributor

Piinks commented Sep 26, 2025

Hey @rkishan516 it looks like you made some updates here, but there are some failing tests. Do you plan to continue with this change?

@rkishan516
Copy link
Contributor Author

Hey @rkishan516 it looks like you made some updates here, but there are some failing tests. Do you plan to continue with this change?

Yes, this is around the corner for landing, just few tests are failing. Will give a try over weekend.

@rkishan516
Copy link
Contributor Author

@chunhtai, @hannah-hyj can you do a last review? all tests are fixed now.

@dkwingsmt
Copy link
Contributor

Gentle nudge @chunhtai (from triage)

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 30, 2025

autosubmit label was removed for flutter/flutter/165173, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@chunhtai
Copy link
Contributor

chunhtai commented Oct 30, 2025

the google test is a valid failure, but the actual bug is in tab widget. will have to fix it before merging this

i will put up a pr to fix the tab first, then we can merge this pr after that

@Piinks
Copy link
Contributor

Piinks commented Nov 10, 2025

It looks like there are some merge conflicts here, but once those are sorted I think the blocking issue has been resolved here.

@chingjun
Copy link
Contributor

Reason for revert: The PR did not finish "Google Testing", and actually caused several failures in Google

@Piinks
Copy link
Contributor

Piinks commented Nov 11, 2025

@rkishan516 please do not manually put PRs in the queue, the autosubmit label should be used. We have to revert this for failing tests that did not complete before it was put in the queue.

@rkishan516
Copy link
Contributor Author

@rkishan516 please do not manually put PRs in the queue, the autosubmit label should be used. We have to revert this for failing tests that did not complete before it was put in the queue.

Sure, I will keep in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: desktop Running on desktop a: tests "flutter test", flutter_test, or one of our tests engine flutter/engine related. See also e: labels. f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. platform-web Web applications specifically platform-windows Building on or for Windows specifically

Projects

Development

Successfully merging this pull request may close these issues.

[a11y] loading indicator should have correct semantics role

6 participants