Skip to content

Commit e8670de

Browse files
authored
Revert "Tweaking Material Chip a11y semantics to match buttons (flutter#60141)" (flutter#60645)
1 parent d30c987 commit e8670de

File tree

2 files changed

+2
-151
lines changed

2 files changed

+2
-151
lines changed

packages/flutter/lib/src/material/chip.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,10 +1944,9 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
19441944
),
19451945
);
19461946
return Semantics(
1947-
button: widget.tapEnabled,
19481947
container: true,
19491948
selected: widget.selected,
1950-
enabled: widget.tapEnabled ? canTap : null,
1949+
enabled: canTap ? widget.isEnabled : null,
19511950
child: result,
19521951
);
19531952
}

packages/flutter/test/material/chip_test.dart

Lines changed: 1 addition & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,10 +1624,6 @@ void main() {
16241624
TestSemantics(
16251625
label: 'test',
16261626
textDirection: TextDirection.ltr,
1627-
flags: <SemanticsFlag>[
1628-
SemanticsFlag.hasEnabledState,
1629-
SemanticsFlag.isButton,
1630-
],
16311627
),
16321628
],
16331629
),
@@ -1666,10 +1662,6 @@ void main() {
16661662
TestSemantics(
16671663
label: 'test',
16681664
textDirection: TextDirection.ltr,
1669-
flags: <SemanticsFlag>[
1670-
SemanticsFlag.hasEnabledState,
1671-
SemanticsFlag.isButton,
1672-
],
16731665
children: <TestSemantics>[
16741666
TestSemantics(
16751667
label: 'Delete',
@@ -1720,7 +1712,6 @@ void main() {
17201712
textDirection: TextDirection.ltr,
17211713
flags: <SemanticsFlag>[
17221714
SemanticsFlag.hasEnabledState,
1723-
SemanticsFlag.isButton,
17241715
SemanticsFlag.isEnabled,
17251716
SemanticsFlag.isFocusable,
17261717
],
@@ -1772,7 +1763,6 @@ void main() {
17721763
textDirection: TextDirection.ltr,
17731764
flags: <SemanticsFlag>[
17741765
SemanticsFlag.hasEnabledState,
1775-
SemanticsFlag.isButton,
17761766
SemanticsFlag.isEnabled,
17771767
SemanticsFlag.isFocusable,
17781768
],
@@ -1818,7 +1808,6 @@ void main() {
18181808
textDirection: TextDirection.ltr,
18191809
flags: <SemanticsFlag>[
18201810
SemanticsFlag.hasEnabledState,
1821-
SemanticsFlag.isButton,
18221811
SemanticsFlag.isEnabled,
18231812
SemanticsFlag.isFocusable,
18241813
SemanticsFlag.isSelected,
@@ -1864,10 +1853,7 @@ void main() {
18641853
TestSemantics(
18651854
label: 'test',
18661855
textDirection: TextDirection.ltr,
1867-
flags: <SemanticsFlag>[
1868-
SemanticsFlag.hasEnabledState,
1869-
SemanticsFlag.isButton,
1870-
],
1856+
flags: <SemanticsFlag>[],
18711857
actions: <SemanticsAction>[],
18721858
),
18731859
],
@@ -1881,140 +1867,6 @@ void main() {
18811867

18821868
semanticsTester.dispose();
18831869
});
1884-
1885-
testWidgets('tapEnabled explicitly false', (WidgetTester tester) async {
1886-
final SemanticsTester semanticsTester = SemanticsTester(tester);
1887-
1888-
await tester.pumpWidget(const MaterialApp(
1889-
home: Material(
1890-
child: RawChip(
1891-
tapEnabled: false,
1892-
label: Text('test'),
1893-
),
1894-
),
1895-
));
1896-
1897-
expect(semanticsTester, hasSemantics(
1898-
TestSemantics.root(
1899-
children: <TestSemantics>[
1900-
TestSemantics(
1901-
textDirection: TextDirection.ltr,
1902-
children: <TestSemantics>[
1903-
TestSemantics(
1904-
children: <TestSemantics>[
1905-
TestSemantics(
1906-
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
1907-
children: <TestSemantics>[
1908-
TestSemantics(
1909-
label: 'test',
1910-
textDirection: TextDirection.ltr,
1911-
flags: <SemanticsFlag>[], // Must not be a button when tapping is disabled.
1912-
actions: <SemanticsAction>[],
1913-
),
1914-
],
1915-
),
1916-
],
1917-
),
1918-
],
1919-
),
1920-
],
1921-
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
1922-
1923-
semanticsTester.dispose();
1924-
});
1925-
1926-
testWidgets('enabled when tapEnabled and canTap', (WidgetTester tester) async {
1927-
final SemanticsTester semanticsTester = SemanticsTester(tester);
1928-
1929-
// These settings make a Chip which can be tapped, both in general and at this moment.
1930-
await tester.pumpWidget(MaterialApp(
1931-
home: Material(
1932-
child: RawChip(
1933-
isEnabled: true,
1934-
tapEnabled: true,
1935-
onPressed: () {},
1936-
label: const Text('test'),
1937-
),
1938-
),
1939-
));
1940-
1941-
expect(semanticsTester, hasSemantics(
1942-
TestSemantics.root(
1943-
children: <TestSemantics>[
1944-
TestSemantics(
1945-
textDirection: TextDirection.ltr,
1946-
children: <TestSemantics>[
1947-
TestSemantics(
1948-
children: <TestSemantics>[
1949-
TestSemantics(
1950-
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
1951-
children: <TestSemantics>[
1952-
TestSemantics(
1953-
label: 'test',
1954-
textDirection: TextDirection.ltr,
1955-
flags: <SemanticsFlag>[
1956-
SemanticsFlag.hasEnabledState,
1957-
SemanticsFlag.isButton,
1958-
SemanticsFlag.isEnabled,
1959-
SemanticsFlag.isFocusable,
1960-
],
1961-
actions: <SemanticsAction>[SemanticsAction.tap],
1962-
),
1963-
],
1964-
),
1965-
],
1966-
),
1967-
],
1968-
),
1969-
],
1970-
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
1971-
1972-
semanticsTester.dispose();
1973-
});
1974-
1975-
testWidgets('disabled when tapEnabled but not canTap', (WidgetTester tester) async {
1976-
final SemanticsTester semanticsTester = SemanticsTester(tester);
1977-
// These settings make a Chip which _could_ be tapped, but not currently (ensures `canTap == false`).
1978-
await tester.pumpWidget(const MaterialApp(
1979-
home: Material(
1980-
child: RawChip(
1981-
isEnabled: true,
1982-
tapEnabled: true,
1983-
label: Text('test'),
1984-
),
1985-
),
1986-
));
1987-
1988-
expect(semanticsTester, hasSemantics(
1989-
TestSemantics.root(
1990-
children: <TestSemantics>[
1991-
TestSemantics(
1992-
textDirection: TextDirection.ltr,
1993-
children: <TestSemantics>[
1994-
TestSemantics(
1995-
children: <TestSemantics>[
1996-
TestSemantics(
1997-
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
1998-
children: <TestSemantics>[
1999-
TestSemantics(
2000-
label: 'test',
2001-
textDirection: TextDirection.ltr,
2002-
flags: <SemanticsFlag>[
2003-
SemanticsFlag.hasEnabledState,
2004-
SemanticsFlag.isButton,
2005-
],
2006-
),
2007-
],
2008-
),
2009-
],
2010-
),
2011-
],
2012-
),
2013-
],
2014-
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
2015-
2016-
semanticsTester.dispose();
2017-
});
20181870
});
20191871

20201872
testWidgets('can be tapped outside of chip delete icon', (WidgetTester tester) async {

0 commit comments

Comments
 (0)