mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Web][a11y] Update selected chips semantics (#172660)
internal: b/430166300 ## 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. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
2505565964
commit
2b72e9cf34
@ -13,7 +13,7 @@ library;
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/foundation.dart' show clampDouble;
|
||||
import 'package:flutter/foundation.dart' show clampDouble, kIsWeb;
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
@ -1502,7 +1502,13 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
|
||||
return Semantics(
|
||||
button: widget.tapEnabled,
|
||||
container: true,
|
||||
selected: widget.selected,
|
||||
// On web, aria-selected only works for certain roles: gridcell, option, row and tab.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-selected
|
||||
// If the role doesn't support aria-selected, aria-current will be set instead in flutter engine.
|
||||
// But in this case, aria-checked makes more sense than aria-current for a selected chip.
|
||||
// So use checked on web instead.
|
||||
selected: kIsWeb ? null : widget.selected,
|
||||
checked: kIsWeb ? widget.selected : null,
|
||||
enabled: widget.tapEnabled ? canTap : null,
|
||||
child: result,
|
||||
);
|
||||
|
||||
@ -2819,7 +2819,8 @@ void main() {
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasSelectedState,
|
||||
if (kIsWeb) SemanticsFlag.hasCheckedState,
|
||||
if (!kIsWeb) SemanticsFlag.hasSelectedState,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isButton,
|
||||
],
|
||||
@ -2868,7 +2869,8 @@ void main() {
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasSelectedState,
|
||||
if (kIsWeb) SemanticsFlag.hasCheckedState,
|
||||
if (!kIsWeb) SemanticsFlag.hasSelectedState,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isButton,
|
||||
],
|
||||
@ -2931,7 +2933,8 @@ void main() {
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasSelectedState,
|
||||
if (kIsWeb) SemanticsFlag.hasCheckedState,
|
||||
if (!kIsWeb) SemanticsFlag.hasSelectedState,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isEnabled,
|
||||
@ -2991,7 +2994,8 @@ void main() {
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasSelectedState,
|
||||
if (kIsWeb) SemanticsFlag.hasCheckedState,
|
||||
if (!kIsWeb) SemanticsFlag.hasSelectedState,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isEnabled,
|
||||
@ -3050,8 +3054,14 @@ void main() {
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isEnabled,
|
||||
SemanticsFlag.isFocusable,
|
||||
SemanticsFlag.hasSelectedState,
|
||||
SemanticsFlag.isSelected,
|
||||
if (kIsWeb) ...<SemanticsFlag>[
|
||||
SemanticsFlag.hasCheckedState,
|
||||
SemanticsFlag.isChecked,
|
||||
],
|
||||
if (!kIsWeb) ...<SemanticsFlag>[
|
||||
SemanticsFlag.hasSelectedState,
|
||||
SemanticsFlag.isSelected,
|
||||
],
|
||||
],
|
||||
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
|
||||
),
|
||||
@ -3100,7 +3110,8 @@ void main() {
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasSelectedState,
|
||||
if (kIsWeb) SemanticsFlag.hasCheckedState,
|
||||
if (!kIsWeb) SemanticsFlag.hasSelectedState,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isButton,
|
||||
],
|
||||
@ -3149,7 +3160,10 @@ void main() {
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
// Must not be a button when tapping is disabled.
|
||||
flags: <SemanticsFlag>[SemanticsFlag.hasSelectedState],
|
||||
flags: <SemanticsFlag>[
|
||||
if (kIsWeb) SemanticsFlag.hasCheckedState,
|
||||
if (!kIsWeb) SemanticsFlag.hasSelectedState,
|
||||
],
|
||||
actions: <SemanticsAction>[],
|
||||
),
|
||||
],
|
||||
@ -3198,7 +3212,8 @@ void main() {
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasSelectedState,
|
||||
if (kIsWeb) SemanticsFlag.hasCheckedState,
|
||||
if (!kIsWeb) SemanticsFlag.hasSelectedState,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isEnabled,
|
||||
@ -3249,7 +3264,8 @@ void main() {
|
||||
label: 'test',
|
||||
textDirection: TextDirection.ltr,
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasSelectedState,
|
||||
if (kIsWeb) SemanticsFlag.hasCheckedState,
|
||||
if (!kIsWeb) SemanticsFlag.hasSelectedState,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isButton,
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user