Unverified Commit a98bfd75 authored by David Shuckerow's avatar David Shuckerow Committed by GitHub

Wrap the ReorderableList's children with a MergeSemantics (#20715)

parent f7864b81
......@@ -391,10 +391,15 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
//
// We also apply the relevant custom accessibility actions for moving the item
// up, down, to the start, and to the end of the list.
return new KeyedSubtree(key: keyIndexGlobalKey, child: new Semantics(
customSemanticsActions: semanticsActions,
child: toWrap,
));
return new KeyedSubtree(
key: keyIndexGlobalKey,
child: new MergeSemantics(
child: new Semantics(
customSemanticsActions: semanticsActions,
child: toWrap,
),
),
);
}
Widget buildDragTarget(BuildContext context, List<Key> acceptedCandidates, List<dynamic> rejectedCandidates) {
......
......@@ -350,6 +350,63 @@ void main() {
handle.dispose();
});
testWidgets("Doesn't hide accessibility when a child declares its own semantics", (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
final Widget reorderableListView = new ReorderableListView(
children: <Widget>[
const SizedBox(
key: Key('List tile 1'),
height: itemHeight,
child: Text('List tile 1'),
),
new SizedBox(
key: const Key('Switch tile'),
height: itemHeight,
child: new Material(
child: new SwitchListTile(
title: const Text('Switch tile'),
value: true,
onChanged: (bool newValue) {},
),
),
),
const SizedBox(
key: Key('List tile 2'),
height: itemHeight,
child: Text('List tile 2'),
),
],
scrollDirection: Axis.vertical,
onReorder: (int oldIndex, int newIndex) {},
);
await tester.pumpWidget(new MaterialApp(
home: new SizedBox(
height: itemHeight * 10,
child: reorderableListView,
),
));
// Get the switch tile's semantics:
final SemanticsData semanticsData = tester.getSemanticsData(find.byKey(const Key('Switch tile')));
// Check for properties of both SwitchTile semantics and the ReorderableListView custom semantics actions.
expect(semanticsData, matchesSemanticsData(
hasToggledState: true,
isToggled: true,
isEnabled: true,
hasEnabledState: true,
label: 'Switch tile',
hasTapAction: true,
customActions: const <CustomSemanticsAction>[
CustomSemanticsAction(label: 'Move up'),
CustomSemanticsAction(label: 'Move down'),
CustomSemanticsAction(label: 'Move to the end'),
CustomSemanticsAction(label: 'Move to the start'),
],
));
handle.dispose();
});
});
});
......
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