Skip to content

Commit f8e8d89

Browse files
authored
Set Semantics.button to true for date widget (#128824)
Fixes #127863 This PR is to set `Semantics.button` to true for date widget in `DatePicker`. https://github.com/flutter/flutter/assets/36861262/b366f25a-6bf3-4e3f-b944-ab71197b73e5
1 parent c3b2175 commit f8e8d89

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,8 @@ class _DayPickerState extends State<_DayPicker> {
10131013
// for the day of month. To do that we prepend day of month to the
10141014
// formatted full date.
10151015
label: '${localizations.formatDecimal(day)}, ${localizations.formatFullDate(dayToBuild)}$semanticLabelSuffix',
1016+
// Set button to true to make the date selectable.
1017+
button: true,
10161018
selected: isSelectedDay,
10171019
excludeSemantics: true,
10181020
child: dayWidget,

packages/flutter/test/material/calendar_date_picker_test.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,152 +688,182 @@ void main() {
688688
// Day grid.
689689
expect(tester.getSemantics(find.text('1')), matchesSemantics(
690690
label: '1, Friday, January 1, 2016',
691+
isButton: true,
691692
hasTapAction: true,
692693
isFocusable: true,
693694
));
694695
expect(tester.getSemantics(find.text('2')), matchesSemantics(
695696
label: '2, Saturday, January 2, 2016',
697+
isButton: true,
696698
hasTapAction: true,
697699
isFocusable: true,
698700
));
699701
expect(tester.getSemantics(find.text('3')), matchesSemantics(
700702
label: '3, Sunday, January 3, 2016, Today',
703+
isButton: true,
701704
hasTapAction: true,
702705
isFocusable: true,
703706
));
704707
expect(tester.getSemantics(find.text('4')), matchesSemantics(
705708
label: '4, Monday, January 4, 2016',
709+
isButton: true,
706710
hasTapAction: true,
707711
isFocusable: true,
708712
));
709713
expect(tester.getSemantics(find.text('5')), matchesSemantics(
710714
label: '5, Tuesday, January 5, 2016',
715+
isButton: true,
711716
hasTapAction: true,
712717
isFocusable: true,
713718
));
714719
expect(tester.getSemantics(find.text('6')), matchesSemantics(
715720
label: '6, Wednesday, January 6, 2016',
721+
isButton: true,
716722
hasTapAction: true,
717723
isFocusable: true,
718724
));
719725
expect(tester.getSemantics(find.text('7')), matchesSemantics(
720726
label: '7, Thursday, January 7, 2016',
727+
isButton: true,
721728
hasTapAction: true,
722729
isFocusable: true,
723730
));
724731
expect(tester.getSemantics(find.text('8')), matchesSemantics(
725732
label: '8, Friday, January 8, 2016',
733+
isButton: true,
726734
hasTapAction: true,
727735
isFocusable: true,
728736
));
729737
expect(tester.getSemantics(find.text('9')), matchesSemantics(
730738
label: '9, Saturday, January 9, 2016',
739+
isButton: true,
731740
hasTapAction: true,
732741
isFocusable: true,
733742
));
734743
expect(tester.getSemantics(find.text('10')), matchesSemantics(
735744
label: '10, Sunday, January 10, 2016',
745+
isButton: true,
736746
hasTapAction: true,
737747
isFocusable: true,
738748
));
739749
expect(tester.getSemantics(find.text('11')), matchesSemantics(
740750
label: '11, Monday, January 11, 2016',
751+
isButton: true,
741752
hasTapAction: true,
742753
isFocusable: true,
743754
));
744755
expect(tester.getSemantics(find.text('12')), matchesSemantics(
745756
label: '12, Tuesday, January 12, 2016',
757+
isButton: true,
746758
hasTapAction: true,
747759
isFocusable: true,
748760
));
749761
expect(tester.getSemantics(find.text('13')), matchesSemantics(
750762
label: '13, Wednesday, January 13, 2016',
763+
isButton: true,
751764
hasTapAction: true,
752765
isFocusable: true,
753766
));
754767
expect(tester.getSemantics(find.text('14')), matchesSemantics(
755768
label: '14, Thursday, January 14, 2016',
769+
isButton: true,
756770
hasTapAction: true,
757771
isFocusable: true,
758772
));
759773
expect(tester.getSemantics(find.text('15')), matchesSemantics(
760774
label: '15, Friday, January 15, 2016',
775+
isButton: true,
761776
hasTapAction: true,
762777
isSelected: true,
763778
isFocusable: true,
764779
));
765780
expect(tester.getSemantics(find.text('16')), matchesSemantics(
766781
label: '16, Saturday, January 16, 2016',
782+
isButton: true,
767783
hasTapAction: true,
768784
isFocusable: true,
769785
));
770786
expect(tester.getSemantics(find.text('17')), matchesSemantics(
771787
label: '17, Sunday, January 17, 2016',
788+
isButton: true,
772789
hasTapAction: true,
773790
isFocusable: true,
774791
));
775792
expect(tester.getSemantics(find.text('18')), matchesSemantics(
776793
label: '18, Monday, January 18, 2016',
794+
isButton: true,
777795
hasTapAction: true,
778796
isFocusable: true,
779797
));
780798
expect(tester.getSemantics(find.text('19')), matchesSemantics(
781799
label: '19, Tuesday, January 19, 2016',
800+
isButton: true,
782801
hasTapAction: true,
783802
isFocusable: true,
784803
));
785804
expect(tester.getSemantics(find.text('20')), matchesSemantics(
786805
label: '20, Wednesday, January 20, 2016',
806+
isButton: true,
787807
hasTapAction: true,
788808
isFocusable: true,
789809
));
790810
expect(tester.getSemantics(find.text('21')), matchesSemantics(
791811
label: '21, Thursday, January 21, 2016',
812+
isButton: true,
792813
hasTapAction: true,
793814
isFocusable: true,
794815
));
795816
expect(tester.getSemantics(find.text('22')), matchesSemantics(
796817
label: '22, Friday, January 22, 2016',
818+
isButton: true,
797819
hasTapAction: true,
798820
isFocusable: true,
799821
));
800822
expect(tester.getSemantics(find.text('23')), matchesSemantics(
801823
label: '23, Saturday, January 23, 2016',
824+
isButton: true,
802825
hasTapAction: true,
803826
isFocusable: true,
804827
));
805828
expect(tester.getSemantics(find.text('24')), matchesSemantics(
806829
label: '24, Sunday, January 24, 2016',
830+
isButton: true,
807831
hasTapAction: true,
808832
isFocusable: true,
809833
));
810834
expect(tester.getSemantics(find.text('25')), matchesSemantics(
811835
label: '25, Monday, January 25, 2016',
836+
isButton: true,
812837
hasTapAction: true,
813838
isFocusable: true,
814839
));
815840
expect(tester.getSemantics(find.text('26')), matchesSemantics(
816841
label: '26, Tuesday, January 26, 2016',
842+
isButton: true,
817843
hasTapAction: true,
818844
isFocusable: true,
819845
));
820846
expect(tester.getSemantics(find.text('27')), matchesSemantics(
821847
label: '27, Wednesday, January 27, 2016',
848+
isButton: true,
822849
hasTapAction: true,
823850
isFocusable: true,
824851
));
825852
expect(tester.getSemantics(find.text('28')), matchesSemantics(
826853
label: '28, Thursday, January 28, 2016',
854+
isButton: true,
827855
hasTapAction: true,
828856
isFocusable: true,
829857
));
830858
expect(tester.getSemantics(find.text('29')), matchesSemantics(
831859
label: '29, Friday, January 29, 2016',
860+
isButton: true,
832861
hasTapAction: true,
833862
isFocusable: true,
834863
));
835864
expect(tester.getSemantics(find.text('30')), matchesSemantics(
836865
label: '30, Saturday, January 30, 2016',
866+
isButton: true,
837867
hasTapAction: true,
838868
isFocusable: true,
839869
));

packages/flutter/test/material/date_picker_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,7 @@ void main() {
12681268

12691269
expect(tester.getSemantics(find.text('3')), matchesSemantics(
12701270
label: '3, Sunday, January 3, 2016, Today',
1271+
isButton: true,
12711272
hasTapAction: true,
12721273
isFocusable: true,
12731274
));

0 commit comments

Comments
 (0)