Skip to content

Commit

Permalink
Fix a [CupertinoDatePicker] semantics bug (#103123)
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-baolin authored May 6, 2022
1 parent eee051a commit a7a72ce
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 0 additions & 2 deletions packages/flutter/lib/src/cupertino/picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,6 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox {
}

void _handleDecrease() {
if (_currentIndex == 0)
return;
controller.jumpToItem(_currentIndex - 1);
}

Expand Down
31 changes: 31 additions & 0 deletions packages/flutter/test/cupertino/date_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,37 @@ void main() {
handle.dispose();
});

// Regression test for https://github.com/flutter/flutter/issues/98567
testWidgets('picker semantics action test', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
debugResetSemanticsIdCounter();
final DateTime initialDate = DateTime(2018, 6, 8);
late DateTime? date;
await tester.pumpWidget(
CupertinoApp(
home: Center(
child: SizedBox(
height: 400.0,
width: 400.0,
child: CupertinoDatePicker(
onDateTimeChanged: (DateTime newDate) => date = newDate,
initialDateTime: initialDate,
maximumDate: initialDate.add(const Duration(days: 2)),
minimumDate: initialDate.subtract(const Duration(days: 2)),
),
),
),
),
);

tester.binding.pipelineOwner.semanticsOwner!.performAction(4, SemanticsAction.decrease);
await tester.pumpAndSettle();

expect(date, DateTime(2018, 6, 7));

handle.dispose();
});

testWidgets('DatePicker adapts to MaterialApp dark mode', (WidgetTester tester) async {
Widget buildDatePicker(Brightness brightness) {
return MaterialApp(
Expand Down

0 comments on commit a7a72ce

Please sign in to comment.