-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Feat: Add a11y for loading indicators #165173
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
base: master
Are you sure you want to change the base?
Conversation
a4da150
to
f6e5619
Compare
@@ -530,6 +530,8 @@ class SemanticsFlag { | |||
static const int _kHasSelectedStateIndex = 1 << 28; | |||
static const int _kHasRequiredStateIndex = 1 << 29; | |||
static const int _kIsRequiredIndex = 1 << 30; | |||
static const int _kIsProgressBarIndex = 1 << 31; | |||
static const int _kIsLoadingSpinnerIndex = 1 << 32; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
semanticsObject, | ||
preferredLabelRepresentation: LabelRepresentation.ariaLabel, | ||
) { | ||
setAriaRole('progressbar'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on the https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/progressbar_role
we should add aria-valuemin, aria-valuemax, aria-valuenow if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, i will add that.
return _buildIndicator(context, _controller.value, textDirection); | ||
}, | ||
return Semantics( | ||
role: SemanticsRole.loadingSpinner, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
f6e5619
to
0034f92
Compare
Is this PR ready for another round of review? (from triage) |
0034f92
to
b7a864f
Compare
Yes @dkwingsmt. |
} | ||
} | ||
return Semantics( | ||
value: widget.value != null ? '${(widget.value ?? 0) * 100}%' : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value: widget.value != null ? '${(widget.value ?? 0) * 100}%' : null, | |
value: widget.value != null ? '${widget.value! * 100}%' : null, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
b7a864f
to
3f35fa6
Compare
d61aae5
to
050ace5
Compare
050ace5
to
cf1d583
Compare
cf1d583
to
99965e8
Compare
6d45f11
to
5e7af8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this overall lgtm to me, just the property type should be string so that it matches the SemanticsProperties.value
@@ -1854,6 +1862,8 @@ base class _NativeSemanticsUpdateBuilder extends NativeFieldWrapperClass1 | |||
List<String>? controlsNodes, | |||
int validationResultIndex, | |||
int inputType, | |||
double minValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably need to be string to match value
/// | ||
/// {@endtemplate} | ||
/// | ||
/// {@macro flutter.semantics.SemanticsProperties.maxValue} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to re macro here, the doc in @template
in this section is still visible when compiling the doc. using macro here will cause it to duplicate the same doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc should also mention this is used in conjunction with [value]
. and a typical usage is a progress indicator
41174e0
to
6fca6dc
Compare
label: semanticsLabel, | ||
role: | ||
expandedSemanticsValue != null ? SemanticsRole.progressBar : SemanticsRole.loadingSpinner, | ||
minValue: '0.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be 0 and maxValue 100?
@@ -135,15 +135,15 @@ sealed class _DebugSemanticsRoleChecks { | |||
SemanticsRole.status => _noLiveRegion, | |||
SemanticsRole.list => _noCheckRequired, | |||
SemanticsRole.listItem => _semanticsListItem, | |||
SemanticsRole.loadingSpinner => _noCheckRequired, | |||
SemanticsRole.progressBar => _noCheckRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should check if it has value, minValue, maxvalue. and ideally value should be within min and max
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let me push the change.
6454d9d
to
d3c22fc
Compare
d3c22fc
to
8e7c200
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi @flutter-zl, can you take a secondary review since this also touch some of the web engine code? Also looks like this pr may need a rebase, the ci seems to act weird |
8e7c200
to
094acc9
Compare
094acc9
to
b5abb59
Compare
LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
autosubmit label was removed for flutter/flutter/165173, because - The status or check suite Linux linux_android_debug_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.
|
@chunhtai I don't know why tests are failing, can you please have a look ? |
Feat: Add a11y for loading indicators
fixes: #161631
Pre-launch Checklist
///
).