Skip to content

Commit

Permalink
Add button semantics in list tile (flutter#151599)
Browse files Browse the repository at this point in the history
fixes: flutter#111960 

## 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
  • Loading branch information
hannah-hyj authored and Buchimi committed Sep 2, 2024
1 parent 44580a5 commit 37b3426
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/flutter/lib/src/material/list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ class ListTile extends StatelessWidget {
autofocus: autofocus,
enableFeedback: enableFeedback ?? tileTheme.enableFeedback ?? true,
child: Semantics(
button: onTap != null || onLongPress != null,
selected: selected,
enabled: enabled,
child: Ink(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,7 @@ void main() {
));

expect(tester.getSemantics(find.byType(CheckboxListTile)), matchesSemantics(
isButton: true,
hasCheckedState: true,
isChecked: true,
hasEnabledState: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/flutter/test/material/expansion_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ void main() {
expect(
tester.getSemantics(find.byType(ListTile).first),
matchesSemantics(
isButton: true,
hasTapAction: true,
hasFocusAction: true,
hasEnabledState: true,
Expand All @@ -742,6 +743,7 @@ void main() {
expect(
tester.getSemantics(find.byType(ListTile).last),
matchesSemantics(
isButton: true,
hasTapAction: true,
hasFocusAction: true,
hasEnabledState: true,
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/material/list_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ void main() {
),
TestSemantics.rootChild(
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocusable,
Expand Down
2 changes: 2 additions & 0 deletions packages/flutter/test/material/radio_list_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ void main() {
TestSemantics(
id: 1,
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
SemanticsFlag.hasCheckedState,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
Expand Down Expand Up @@ -441,6 +442,7 @@ void main() {
TestSemantics(
id: 1,
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
SemanticsFlag.hasCheckedState,
SemanticsFlag.isChecked,
SemanticsFlag.hasEnabledState,
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/material/reorderable_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ void main() {
return false;
});
expect(child, matchesSemantics(
isButton: true,
hasToggledState: true,
isToggled: true,
isEnabled: true,
Expand Down
3 changes: 3 additions & 0 deletions packages/flutter/test/material/switch_list_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void main() {
id: 1,
rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
SemanticsFlag.hasEnabledState,
SemanticsFlag.hasToggledState,
SemanticsFlag.isEnabled,
Expand All @@ -86,6 +87,7 @@ void main() {
rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
transform: Matrix4.translationValues(0.0, 56.0, 0.0),
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
SemanticsFlag.hasCheckedState,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isChecked,
Expand All @@ -100,6 +102,7 @@ void main() {
rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
transform: Matrix4.translationValues(0.0, 112.0, 0.0),
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
SemanticsFlag.hasCheckedState,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
Expand Down

0 comments on commit 37b3426

Please sign in to comment.