Commit aeb12144 authored by Anthony's avatar Anthony Committed by Flutter GitHub Bot

Use a separately focusable semantics node for the chip delete icon (#48740)

parent b04dc46a
...@@ -1784,7 +1784,10 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip ...@@ -1784,7 +1784,10 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
if (!hasDeleteButton) { if (!hasDeleteButton) {
return null; return null;
} }
return _wrapWithTooltip( return Semantics(
container: true,
button: true,
child: _wrapWithTooltip(
widget.deleteButtonTooltipMessage ?? MaterialLocalizations.of(context)?.deleteButtonTooltip, widget.deleteButtonTooltipMessage ?? MaterialLocalizations.of(context)?.deleteButtonTooltip,
widget.onDeleted, widget.onDeleted,
GestureDetector( GestureDetector(
...@@ -1803,6 +1806,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip ...@@ -1803,6 +1806,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
child: widget.deleteIcon, child: widget.deleteIcon,
), ),
), ),
),
); );
} }
......
...@@ -1630,6 +1630,50 @@ void main() { ...@@ -1630,6 +1630,50 @@ void main() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgets('delete', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(MaterialApp(
home: Material(
child: RawChip(
label: const Text('test'),
onDeleted: () { },
),
),
));
expect(semanticsTester, hasSemantics(
TestSemantics.root(
children: <TestSemantics>[
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
label: 'test',
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
label: 'Delete',
actions: <SemanticsAction>[SemanticsAction.tap],
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
],
),
],
),
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semanticsTester.dispose();
});
testWidgets('with onPressed', (WidgetTester tester) async { testWidgets('with onPressed', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment