mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Use a separately focusable semantics node for the chip delete icon (#48740)
This commit is contained in:
parent
b04dc46ada
commit
aeb12144e6
|
@ -1784,23 +1784,27 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
|
|||
if (!hasDeleteButton) {
|
||||
return null;
|
||||
}
|
||||
return _wrapWithTooltip(
|
||||
widget.deleteButtonTooltipMessage ?? MaterialLocalizations.of(context)?.deleteButtonTooltip,
|
||||
widget.onDeleted,
|
||||
GestureDetector(
|
||||
key: deleteIconKey,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: widget.isEnabled
|
||||
return Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
child: _wrapWithTooltip(
|
||||
widget.deleteButtonTooltipMessage ?? MaterialLocalizations.of(context)?.deleteButtonTooltip,
|
||||
widget.onDeleted,
|
||||
GestureDetector(
|
||||
key: deleteIconKey,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: widget.isEnabled
|
||||
? () {
|
||||
Feedback.forTap(context);
|
||||
widget.onDeleted();
|
||||
}
|
||||
: null,
|
||||
child: IconTheme(
|
||||
data: theme.iconTheme.copyWith(
|
||||
color: widget.deleteIconColor ?? chipTheme.deleteIconColor,
|
||||
child: IconTheme(
|
||||
data: theme.iconTheme.copyWith(
|
||||
color: widget.deleteIconColor ?? chipTheme.deleteIconColor,
|
||||
),
|
||||
child: widget.deleteIcon,
|
||||
),
|
||||
child: widget.deleteIcon,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -1630,6 +1630,50 @@ void main() {
|
|||
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 {
|
||||
final SemanticsTester semanticsTester = SemanticsTester(tester);
|
||||
|
||||
|
|
Loading…
Reference in a new issue