@sproutsocial/racine 8.6.1-collapsible-fix.0 → 8.6.3-dar10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/__flow__/Collapsible/index.js +1 -1
- package/__flow__/Collapsible/styles.js +5 -4
- package/__flow__/Listbox/__snapshots__/index.test.js.snap +84 -42
- package/__flow__/Listbox/index.stories.js +33 -0
- package/__flow__/Listbox/index.test.js +52 -2
- package/__flow__/Menu/__snapshots__/index.test.js.snap +4 -0
- package/__flow__/Menu/hooks.js +8 -3
- package/__flow__/Menu/index.flow.js +1 -0
- package/__flow__/Menu/index.js +31 -4
- package/__flow__/Menu/index.stories.js +20 -0
- package/__flow__/Menu/styles.js +4 -0
- package/commonjs/Collapsible/index.js +1 -1
- package/commonjs/Collapsible/styles.js +5 -3
- package/commonjs/Menu/hooks.js +12 -3
- package/commonjs/Menu/index.js +26 -6
- package/commonjs/Menu/styles.js +4 -2
- package/dist/themes/dark.scss +569 -0
- package/dist/themes/default.scss +668 -0
- package/lib/Collapsible/index.js +1 -1
- package/lib/Collapsible/styles.js +5 -3
- package/lib/Menu/hooks.js +12 -3
- package/lib/Menu/index.js +26 -6
- package/lib/Menu/styles.js +4 -2
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 8.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 039da3f: Address visual bug on collapsible shadow
|
|
8
|
+
|
|
9
|
+
## 8.6.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- c46c79d: Pressing space on a filter input in listbox triggers a submit, preventing users from entering text with spaces. This fix changes the behavior such that if the input is in focus, the space won't trigger a select.
|
|
14
|
+
- b34b463: Invert the icon colors in menu items to mirror the text behavior.
|
|
15
|
+
|
|
3
16
|
## 8.6.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -103,7 +103,7 @@ const Panel = ({ children, ...rest }) => {
|
|
|
103
103
|
|
|
104
104
|
return (
|
|
105
105
|
<CollapsingBox
|
|
106
|
-
|
|
106
|
+
hasShadow={collapsedHeight || openHeight > 0}
|
|
107
107
|
scrollable={isOpen}
|
|
108
108
|
maxHeight={isOpen ? maxHeight : collapsedHeight}
|
|
109
109
|
minHeight={collapsedHeight}
|
|
@@ -10,8 +10,9 @@ export const CollapsingBox = styled<typeof Box, TypeTheme, *>(Box)`
|
|
|
10
10
|
will-change: max-height;
|
|
11
11
|
position: relative;
|
|
12
12
|
overflow: auto;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
${({ hasShadow, theme, scrollable }) =>
|
|
14
|
+
hasShadow
|
|
15
|
+
? `background: /* Shadow covers */ linear-gradient(
|
|
15
16
|
transparent 30%,
|
|
16
17
|
rgba(255, 255, 255, 0)
|
|
17
18
|
),
|
|
@@ -31,6 +32,6 @@ export const CollapsingBox = styled<typeof Box, TypeTheme, *>(Box)`
|
|
|
31
32
|
background-repeat: no-repeat;
|
|
32
33
|
background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
|
|
33
34
|
background-attachment: local, local, scroll, scroll;
|
|
34
|
-
${
|
|
35
|
-
|
|
35
|
+
${scrollable ? `overflow: auto` : `overflow: hidden`};`
|
|
36
|
+
: ""}
|
|
36
37
|
`;
|
|
@@ -142,7 +142,7 @@ html .c5 {
|
|
|
142
142
|
class="c1 c2"
|
|
143
143
|
data-qa-button=""
|
|
144
144
|
data-qa-button-isdisabled="false"
|
|
145
|
-
id="MenuButton-
|
|
145
|
+
id="MenuButton-20"
|
|
146
146
|
type="button"
|
|
147
147
|
>
|
|
148
148
|
Select a fruit
|
|
@@ -436,6 +436,10 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
436
436
|
background-color: #364141;
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
+
.c4 .Icon-svg {
|
|
440
|
+
color: #FFFFFF;
|
|
441
|
+
}
|
|
442
|
+
|
|
439
443
|
.c4:focus,
|
|
440
444
|
.c4:hover {
|
|
441
445
|
color: #364141;
|
|
@@ -535,7 +539,7 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
535
539
|
|
|
536
540
|
<div>
|
|
537
541
|
<ul
|
|
538
|
-
aria-activedescendant="MenuItem-
|
|
542
|
+
aria-activedescendant="MenuItem-28"
|
|
539
543
|
aria-multiselectable="true"
|
|
540
544
|
class="c0 c1"
|
|
541
545
|
overflow="hidden"
|
|
@@ -552,7 +556,7 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
552
556
|
class="c2 c4"
|
|
553
557
|
data-qa-menu-item="Apple"
|
|
554
558
|
data-value="Apple"
|
|
555
|
-
id="MenuItem-
|
|
559
|
+
id="MenuItem-28"
|
|
556
560
|
role="menuitemcheckbox"
|
|
557
561
|
tabindex="-1"
|
|
558
562
|
value="Apple"
|
|
@@ -565,10 +569,10 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
565
569
|
class="c5"
|
|
566
570
|
>
|
|
567
571
|
<input
|
|
568
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
572
|
+
data-qa-checkbox="Checkbox-MenuItem-28"
|
|
569
573
|
data-qa-checkbox-ischecked="false"
|
|
570
574
|
data-qa-checkbox-isdisabled="false"
|
|
571
|
-
id="Checkbox-MenuItem-
|
|
575
|
+
id="Checkbox-MenuItem-28"
|
|
572
576
|
tabindex="-1"
|
|
573
577
|
type="checkbox"
|
|
574
578
|
value=""
|
|
@@ -586,7 +590,7 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
586
590
|
class="c2 c6"
|
|
587
591
|
data-qa-menu-item="Banana"
|
|
588
592
|
data-value="Banana"
|
|
589
|
-
id="MenuItem-
|
|
593
|
+
id="MenuItem-29"
|
|
590
594
|
role="menuitemcheckbox"
|
|
591
595
|
tabindex="-1"
|
|
592
596
|
value="Banana"
|
|
@@ -599,10 +603,10 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
599
603
|
class="c5"
|
|
600
604
|
>
|
|
601
605
|
<input
|
|
602
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
606
|
+
data-qa-checkbox="Checkbox-MenuItem-29"
|
|
603
607
|
data-qa-checkbox-ischecked="false"
|
|
604
608
|
data-qa-checkbox-isdisabled="false"
|
|
605
|
-
id="Checkbox-MenuItem-
|
|
609
|
+
id="Checkbox-MenuItem-29"
|
|
606
610
|
tabindex="-1"
|
|
607
611
|
type="checkbox"
|
|
608
612
|
value=""
|
|
@@ -620,7 +624,7 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
620
624
|
class="c2 c6"
|
|
621
625
|
data-qa-menu-item="Orange"
|
|
622
626
|
data-value="Orange"
|
|
623
|
-
id="MenuItem-
|
|
627
|
+
id="MenuItem-30"
|
|
624
628
|
role="menuitemcheckbox"
|
|
625
629
|
tabindex="-1"
|
|
626
630
|
value="Orange"
|
|
@@ -633,10 +637,10 @@ exports[`Listbox AsListbox with checkboxes should match snapshot 1`] = `
|
|
|
633
637
|
class="c5"
|
|
634
638
|
>
|
|
635
639
|
<input
|
|
636
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
640
|
+
data-qa-checkbox="Checkbox-MenuItem-30"
|
|
637
641
|
data-qa-checkbox-ischecked="false"
|
|
638
642
|
data-qa-checkbox-isdisabled="false"
|
|
639
|
-
id="Checkbox-MenuItem-
|
|
643
|
+
id="Checkbox-MenuItem-30"
|
|
640
644
|
tabindex="-1"
|
|
641
645
|
type="checkbox"
|
|
642
646
|
value=""
|
|
@@ -717,6 +721,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
717
721
|
background-color: #364141;
|
|
718
722
|
}
|
|
719
723
|
|
|
724
|
+
.c5 .Icon-svg {
|
|
725
|
+
color: #FFFFFF;
|
|
726
|
+
}
|
|
727
|
+
|
|
720
728
|
.c5:focus,
|
|
721
729
|
.c5:hover {
|
|
722
730
|
color: #364141;
|
|
@@ -873,7 +881,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
873
881
|
|
|
874
882
|
<div>
|
|
875
883
|
<ul
|
|
876
|
-
aria-activedescendant="MenuItem-
|
|
884
|
+
aria-activedescendant="MenuItem-34"
|
|
877
885
|
aria-multiselectable="true"
|
|
878
886
|
class="c0 c1"
|
|
879
887
|
overflow="hidden"
|
|
@@ -906,7 +914,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
906
914
|
class="c2 c5"
|
|
907
915
|
data-qa-menu-item="Apple"
|
|
908
916
|
data-value="Apple"
|
|
909
|
-
id="MenuItem-
|
|
917
|
+
id="MenuItem-34"
|
|
910
918
|
role="menuitemcheckbox"
|
|
911
919
|
tabindex="-1"
|
|
912
920
|
value="Apple"
|
|
@@ -919,10 +927,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
919
927
|
class="c6"
|
|
920
928
|
>
|
|
921
929
|
<input
|
|
922
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
930
|
+
data-qa-checkbox="Checkbox-MenuItem-34"
|
|
923
931
|
data-qa-checkbox-ischecked="false"
|
|
924
932
|
data-qa-checkbox-isdisabled="false"
|
|
925
|
-
id="Checkbox-MenuItem-
|
|
933
|
+
id="Checkbox-MenuItem-34"
|
|
926
934
|
tabindex="-1"
|
|
927
935
|
type="checkbox"
|
|
928
936
|
value=""
|
|
@@ -940,7 +948,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
940
948
|
class="c2 c7"
|
|
941
949
|
data-qa-menu-item="Banana"
|
|
942
950
|
data-value="Banana"
|
|
943
|
-
id="MenuItem-
|
|
951
|
+
id="MenuItem-35"
|
|
944
952
|
role="menuitemcheckbox"
|
|
945
953
|
tabindex="-1"
|
|
946
954
|
value="Banana"
|
|
@@ -953,10 +961,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
953
961
|
class="c6"
|
|
954
962
|
>
|
|
955
963
|
<input
|
|
956
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
964
|
+
data-qa-checkbox="Checkbox-MenuItem-35"
|
|
957
965
|
data-qa-checkbox-ischecked="false"
|
|
958
966
|
data-qa-checkbox-isdisabled="false"
|
|
959
|
-
id="Checkbox-MenuItem-
|
|
967
|
+
id="Checkbox-MenuItem-35"
|
|
960
968
|
tabindex="-1"
|
|
961
969
|
type="checkbox"
|
|
962
970
|
value=""
|
|
@@ -974,7 +982,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
974
982
|
class="c2 c7"
|
|
975
983
|
data-qa-menu-item="Orange"
|
|
976
984
|
data-value="Orange"
|
|
977
|
-
id="MenuItem-
|
|
985
|
+
id="MenuItem-36"
|
|
978
986
|
role="menuitemcheckbox"
|
|
979
987
|
tabindex="-1"
|
|
980
988
|
value="Orange"
|
|
@@ -987,10 +995,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
987
995
|
class="c6"
|
|
988
996
|
>
|
|
989
997
|
<input
|
|
990
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
998
|
+
data-qa-checkbox="Checkbox-MenuItem-36"
|
|
991
999
|
data-qa-checkbox-ischecked="false"
|
|
992
1000
|
data-qa-checkbox-isdisabled="false"
|
|
993
|
-
id="Checkbox-MenuItem-
|
|
1001
|
+
id="Checkbox-MenuItem-36"
|
|
994
1002
|
tabindex="-1"
|
|
995
1003
|
type="checkbox"
|
|
996
1004
|
value=""
|
|
@@ -1008,7 +1016,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1008
1016
|
class="c2 c7"
|
|
1009
1017
|
data-qa-menu-item="Tomato"
|
|
1010
1018
|
data-value="Tomato"
|
|
1011
|
-
id="MenuItem-
|
|
1019
|
+
id="MenuItem-37"
|
|
1012
1020
|
role="menuitemcheckbox"
|
|
1013
1021
|
tabindex="-1"
|
|
1014
1022
|
value="Tomato"
|
|
@@ -1021,10 +1029,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1021
1029
|
class="c6"
|
|
1022
1030
|
>
|
|
1023
1031
|
<input
|
|
1024
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1032
|
+
data-qa-checkbox="Checkbox-MenuItem-37"
|
|
1025
1033
|
data-qa-checkbox-ischecked="false"
|
|
1026
1034
|
data-qa-checkbox-isdisabled="false"
|
|
1027
|
-
id="Checkbox-MenuItem-
|
|
1035
|
+
id="Checkbox-MenuItem-37"
|
|
1028
1036
|
tabindex="-1"
|
|
1029
1037
|
type="checkbox"
|
|
1030
1038
|
value=""
|
|
@@ -1042,7 +1050,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1042
1050
|
class="c2 c7"
|
|
1043
1051
|
data-qa-menu-item="Cucumber"
|
|
1044
1052
|
data-value="Cucumber"
|
|
1045
|
-
id="MenuItem-
|
|
1053
|
+
id="MenuItem-38"
|
|
1046
1054
|
role="menuitemcheckbox"
|
|
1047
1055
|
tabindex="-1"
|
|
1048
1056
|
value="Cucumber"
|
|
@@ -1055,10 +1063,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1055
1063
|
class="c6"
|
|
1056
1064
|
>
|
|
1057
1065
|
<input
|
|
1058
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1066
|
+
data-qa-checkbox="Checkbox-MenuItem-38"
|
|
1059
1067
|
data-qa-checkbox-ischecked="false"
|
|
1060
1068
|
data-qa-checkbox-isdisabled="false"
|
|
1061
|
-
id="Checkbox-MenuItem-
|
|
1069
|
+
id="Checkbox-MenuItem-38"
|
|
1062
1070
|
tabindex="-1"
|
|
1063
1071
|
type="checkbox"
|
|
1064
1072
|
value=""
|
|
@@ -1076,7 +1084,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1076
1084
|
class="c2 c7"
|
|
1077
1085
|
data-qa-menu-item="Squash"
|
|
1078
1086
|
data-value="Squash"
|
|
1079
|
-
id="MenuItem-
|
|
1087
|
+
id="MenuItem-39"
|
|
1080
1088
|
role="menuitemcheckbox"
|
|
1081
1089
|
tabindex="-1"
|
|
1082
1090
|
value="Squash"
|
|
@@ -1089,10 +1097,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1089
1097
|
class="c6"
|
|
1090
1098
|
>
|
|
1091
1099
|
<input
|
|
1092
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1100
|
+
data-qa-checkbox="Checkbox-MenuItem-39"
|
|
1093
1101
|
data-qa-checkbox-ischecked="false"
|
|
1094
1102
|
data-qa-checkbox-isdisabled="false"
|
|
1095
|
-
id="Checkbox-MenuItem-
|
|
1103
|
+
id="Checkbox-MenuItem-39"
|
|
1096
1104
|
tabindex="-1"
|
|
1097
1105
|
type="checkbox"
|
|
1098
1106
|
value=""
|
|
@@ -1110,7 +1118,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1110
1118
|
class="c2 c7"
|
|
1111
1119
|
data-qa-menu-item="Cantaloupe"
|
|
1112
1120
|
data-value="Cantaloupe"
|
|
1113
|
-
id="MenuItem-
|
|
1121
|
+
id="MenuItem-40"
|
|
1114
1122
|
role="menuitemcheckbox"
|
|
1115
1123
|
tabindex="-1"
|
|
1116
1124
|
value="Cantaloupe"
|
|
@@ -1123,10 +1131,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1123
1131
|
class="c6"
|
|
1124
1132
|
>
|
|
1125
1133
|
<input
|
|
1126
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1134
|
+
data-qa-checkbox="Checkbox-MenuItem-40"
|
|
1127
1135
|
data-qa-checkbox-ischecked="false"
|
|
1128
1136
|
data-qa-checkbox-isdisabled="false"
|
|
1129
|
-
id="Checkbox-MenuItem-
|
|
1137
|
+
id="Checkbox-MenuItem-40"
|
|
1130
1138
|
tabindex="-1"
|
|
1131
1139
|
type="checkbox"
|
|
1132
1140
|
value=""
|
|
@@ -1144,7 +1152,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1144
1152
|
class="c2 c7"
|
|
1145
1153
|
data-qa-menu-item="Jackalope"
|
|
1146
1154
|
data-value="Jackalope"
|
|
1147
|
-
id="MenuItem-
|
|
1155
|
+
id="MenuItem-41"
|
|
1148
1156
|
role="menuitemcheckbox"
|
|
1149
1157
|
tabindex="-1"
|
|
1150
1158
|
value="Jackalope"
|
|
@@ -1157,10 +1165,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1157
1165
|
class="c6"
|
|
1158
1166
|
>
|
|
1159
1167
|
<input
|
|
1160
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1168
|
+
data-qa-checkbox="Checkbox-MenuItem-41"
|
|
1161
1169
|
data-qa-checkbox-ischecked="false"
|
|
1162
1170
|
data-qa-checkbox-isdisabled="false"
|
|
1163
|
-
id="Checkbox-MenuItem-
|
|
1171
|
+
id="Checkbox-MenuItem-41"
|
|
1164
1172
|
tabindex="-1"
|
|
1165
1173
|
type="checkbox"
|
|
1166
1174
|
value=""
|
|
@@ -1178,7 +1186,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1178
1186
|
class="c2 c7"
|
|
1179
1187
|
data-qa-menu-item="Lingonberry"
|
|
1180
1188
|
data-value="Lingonberry"
|
|
1181
|
-
id="MenuItem-
|
|
1189
|
+
id="MenuItem-42"
|
|
1182
1190
|
role="menuitemcheckbox"
|
|
1183
1191
|
tabindex="-1"
|
|
1184
1192
|
value="Lingonberry"
|
|
@@ -1191,10 +1199,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1191
1199
|
class="c6"
|
|
1192
1200
|
>
|
|
1193
1201
|
<input
|
|
1194
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1202
|
+
data-qa-checkbox="Checkbox-MenuItem-42"
|
|
1195
1203
|
data-qa-checkbox-ischecked="false"
|
|
1196
1204
|
data-qa-checkbox-isdisabled="false"
|
|
1197
|
-
id="Checkbox-MenuItem-
|
|
1205
|
+
id="Checkbox-MenuItem-42"
|
|
1198
1206
|
tabindex="-1"
|
|
1199
1207
|
type="checkbox"
|
|
1200
1208
|
value=""
|
|
@@ -1212,7 +1220,7 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1212
1220
|
class="c2 c7"
|
|
1213
1221
|
data-qa-menu-item="Dingleberry"
|
|
1214
1222
|
data-value="Dingleberry"
|
|
1215
|
-
id="MenuItem-
|
|
1223
|
+
id="MenuItem-43"
|
|
1216
1224
|
role="menuitemcheckbox"
|
|
1217
1225
|
tabindex="-1"
|
|
1218
1226
|
value="Dingleberry"
|
|
@@ -1225,10 +1233,10 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1225
1233
|
class="c6"
|
|
1226
1234
|
>
|
|
1227
1235
|
<input
|
|
1228
|
-
data-qa-checkbox="Checkbox-MenuItem-
|
|
1236
|
+
data-qa-checkbox="Checkbox-MenuItem-43"
|
|
1229
1237
|
data-qa-checkbox-ischecked="false"
|
|
1230
1238
|
data-qa-checkbox-isdisabled="false"
|
|
1231
|
-
id="Checkbox-MenuItem-
|
|
1239
|
+
id="Checkbox-MenuItem-43"
|
|
1232
1240
|
tabindex="-1"
|
|
1233
1241
|
type="checkbox"
|
|
1234
1242
|
value=""
|
|
@@ -1241,6 +1249,40 @@ exports[`Listbox AsListbox with filter input should match snapshot 1`] = `
|
|
|
1241
1249
|
</div>
|
|
1242
1250
|
</div>
|
|
1243
1251
|
</li>
|
|
1252
|
+
<li
|
|
1253
|
+
aria-checked="false"
|
|
1254
|
+
class="c2 c7"
|
|
1255
|
+
data-qa-menu-item="Kaffir Lime"
|
|
1256
|
+
data-value="Kaffir Lime"
|
|
1257
|
+
id="MenuItem-44"
|
|
1258
|
+
role="menuitemcheckbox"
|
|
1259
|
+
tabindex="-1"
|
|
1260
|
+
value="Kaffir Lime"
|
|
1261
|
+
>
|
|
1262
|
+
<div
|
|
1263
|
+
style="display: flex; align-items: center; justify-content: space-between;"
|
|
1264
|
+
>
|
|
1265
|
+
<span
|
|
1266
|
+
aria-hidden="true"
|
|
1267
|
+
class="c6"
|
|
1268
|
+
>
|
|
1269
|
+
<input
|
|
1270
|
+
data-qa-checkbox="Checkbox-MenuItem-44"
|
|
1271
|
+
data-qa-checkbox-ischecked="false"
|
|
1272
|
+
data-qa-checkbox-isdisabled="false"
|
|
1273
|
+
id="Checkbox-MenuItem-44"
|
|
1274
|
+
tabindex="-1"
|
|
1275
|
+
type="checkbox"
|
|
1276
|
+
value=""
|
|
1277
|
+
/>
|
|
1278
|
+
</span>
|
|
1279
|
+
<div
|
|
1280
|
+
style="flex-grow: 1; word-break: break-word; min-width: 0;"
|
|
1281
|
+
>
|
|
1282
|
+
Kaffir Lime
|
|
1283
|
+
</div>
|
|
1284
|
+
</div>
|
|
1285
|
+
</li>
|
|
1244
1286
|
</div>
|
|
1245
1287
|
</ul>
|
|
1246
1288
|
</div>
|
|
@@ -196,3 +196,36 @@ export const BigVirtualizedExample = () => {
|
|
|
196
196
|
</Box>
|
|
197
197
|
);
|
|
198
198
|
};
|
|
199
|
+
|
|
200
|
+
const ListboxFilterInput = () => {
|
|
201
|
+
const { value, onChange } = useSelect({ initialValue: null });
|
|
202
|
+
const { inputValue } = useSelect({ initialValue: null });
|
|
203
|
+
return (
|
|
204
|
+
<>
|
|
205
|
+
<Text>{inputValue}</Text>
|
|
206
|
+
<ListboxButton
|
|
207
|
+
minWidth="200px"
|
|
208
|
+
aria-label="Favorite fruit"
|
|
209
|
+
content={
|
|
210
|
+
<Listbox onChange={onChange} value={value} width="200px">
|
|
211
|
+
<Listbox.Group>
|
|
212
|
+
<Listbox.FilterInput placeholder="Filter items" mb={300} />
|
|
213
|
+
<Listbox.Item value="Apple">Apple</Listbox.Item>
|
|
214
|
+
<Listbox.Item value="Orange">Orange</Listbox.Item>
|
|
215
|
+
<Listbox.Item value="Banana">Banana</Listbox.Item>
|
|
216
|
+
<Listbox.Item value="Kaffir Lime">Kaffir Lime</Listbox.Item>
|
|
217
|
+
</Listbox.Group>
|
|
218
|
+
</Listbox>
|
|
219
|
+
}
|
|
220
|
+
>
|
|
221
|
+
{value || "Select a fruit"}
|
|
222
|
+
</ListboxButton>
|
|
223
|
+
</>
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export const FilterInput = () => <ListboxFilterInput />;
|
|
228
|
+
|
|
229
|
+
FilterInput.story = {
|
|
230
|
+
name: "FilterInput",
|
|
231
|
+
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
render,
|
|
4
|
+
fireEvent,
|
|
5
|
+
cleanup,
|
|
6
|
+
userEvent,
|
|
7
|
+
} from "../utils/react-testing-library";
|
|
3
8
|
import Listbox, { ListboxButton } from "./";
|
|
4
9
|
import { useSelect, useMultiselect } from "../utils/hooks";
|
|
5
10
|
import { MENU_ITEM_ROLES } from "../Menu/constants";
|
|
@@ -16,6 +21,7 @@ const lotsOfFruit = [
|
|
|
16
21
|
"Jackalope",
|
|
17
22
|
"Lingonberry",
|
|
18
23
|
"Dingleberry",
|
|
24
|
+
"Kaffir Lime",
|
|
19
25
|
];
|
|
20
26
|
const mockOnClick = jest.fn();
|
|
21
27
|
|
|
@@ -182,6 +188,26 @@ describe("Listbox", () => {
|
|
|
182
188
|
expect(await findByText(fruit[1])).toBeInTheDocument();
|
|
183
189
|
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
184
190
|
});
|
|
191
|
+
|
|
192
|
+
it("should trigger select on enter", async () => {
|
|
193
|
+
const { findByText, queryByLabelText } = render(<AsListbox />);
|
|
194
|
+
const button = queryByLabelText(/Select a fruit/);
|
|
195
|
+
|
|
196
|
+
fireEvent.click(button);
|
|
197
|
+
userEvent.keyboard("{enter}");
|
|
198
|
+
expect(await findByText(fruit[0])).toBeInTheDocument();
|
|
199
|
+
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("should trigger select on space", async () => {
|
|
203
|
+
const { findByText, queryByLabelText } = render(<AsListbox />);
|
|
204
|
+
const button = queryByLabelText(/Select a fruit/);
|
|
205
|
+
|
|
206
|
+
fireEvent.click(button);
|
|
207
|
+
userEvent.keyboard("{space}");
|
|
208
|
+
expect(await findByText(fruit[0])).toBeInTheDocument();
|
|
209
|
+
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
210
|
+
});
|
|
185
211
|
});
|
|
186
212
|
|
|
187
213
|
describe("AsListbox multiselect", () => {
|
|
@@ -252,9 +278,33 @@ describe("Listbox", () => {
|
|
|
252
278
|
<AsListboxWithFilterInput />
|
|
253
279
|
);
|
|
254
280
|
const input = queryByLabelText("Search fruit...");
|
|
255
|
-
expect(queryAllByRole("menuitemcheckbox")).toHaveLength(
|
|
281
|
+
expect(queryAllByRole("menuitemcheckbox")).toHaveLength(11);
|
|
256
282
|
fireEvent.change(input, { target: { value: "berry" } });
|
|
257
283
|
expect(queryAllByRole("menuitemcheckbox")).toHaveLength(2);
|
|
258
284
|
});
|
|
285
|
+
|
|
286
|
+
it("should allow spaces to be typed in the input", async () => {
|
|
287
|
+
const { queryByLabelText, queryAllByRole } = render(
|
|
288
|
+
<AsListboxWithFilterInput />
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
const input = queryByLabelText("Search fruit...");
|
|
292
|
+
userEvent.type(input, "Kaffir{space}L");
|
|
293
|
+
expect(queryAllByRole("menuitemcheckbox")).toHaveLength(1);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("should trigger a submit on space if the input is not focused", async () => {
|
|
297
|
+
const { queryByRole } = render(<AsListboxWithFilterInput />);
|
|
298
|
+
|
|
299
|
+
// tab focus away from input
|
|
300
|
+
userEvent.tab();
|
|
301
|
+
userEvent.keyboard("{space}");
|
|
302
|
+
const firstItem = queryByRole(MENU_ITEM_ROLES.CHECKBOX, {
|
|
303
|
+
name: fruit[0],
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
expect(firstItem).toHaveAttribute("aria-checked", "true");
|
|
307
|
+
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
308
|
+
});
|
|
259
309
|
});
|
|
260
310
|
});
|
package/__flow__/Menu/hooks.js
CHANGED
|
@@ -24,6 +24,7 @@ export const MenuContext = createContext<TypeMenuContext>({
|
|
|
24
24
|
selectionIndex: 0,
|
|
25
25
|
filterQuery: "",
|
|
26
26
|
filteredItems: null,
|
|
27
|
+
isFilterInputFocused: false,
|
|
27
28
|
},
|
|
28
29
|
setState: () => {},
|
|
29
30
|
selectCallbacks: {
|
|
@@ -75,7 +76,7 @@ export function useMenuKeyDown() {
|
|
|
75
76
|
selectCallbacks,
|
|
76
77
|
setState,
|
|
77
78
|
multiselect,
|
|
78
|
-
state: { filterQuery, selectionIndex, filteredItems },
|
|
79
|
+
state: { filterQuery, selectionIndex, filteredItems, isFilterInputFocused },
|
|
79
80
|
} = useContext(MenuContext);
|
|
80
81
|
const { closePopout, closeOnItemClick } = useContext(MenuButtonContext);
|
|
81
82
|
const { descendants: items } = useContext(MenuDescendantContext);
|
|
@@ -142,10 +143,14 @@ export function useMenuKeyDown() {
|
|
|
142
143
|
handleKeyDown: wrapEvent<SyntheticKeyboardEvent<>>(
|
|
143
144
|
function (event) {
|
|
144
145
|
const { key } = event;
|
|
145
|
-
|
|
146
146
|
switch (key) {
|
|
147
|
-
case "Enter":
|
|
148
147
|
case " ":
|
|
148
|
+
if (isFilterInputFocused) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// falls through
|
|
152
|
+
// eslint-disable-next-line no-fallthrough
|
|
153
|
+
case "Enter":
|
|
149
154
|
const selected = items[selectionIndex];
|
|
150
155
|
|
|
151
156
|
if (selected) {
|
package/__flow__/Menu/index.js
CHANGED
|
@@ -308,14 +308,40 @@ export const MenuDivider = (props: any) => (
|
|
|
308
308
|
);
|
|
309
309
|
|
|
310
310
|
const MenuFilterInput = (props: React$ElementConfig<typeof Input>) => {
|
|
311
|
+
const { onChange, onFocus, onBlur } = props;
|
|
311
312
|
const { state, setState } = useContext(MenuContext);
|
|
312
|
-
const
|
|
313
|
-
(event) =>
|
|
314
|
-
|
|
313
|
+
const handleOnChange = useCallback(
|
|
314
|
+
(event, value) => {
|
|
315
|
+
onChange && onChange(event, value);
|
|
316
|
+
setState({ filterQuery: value });
|
|
317
|
+
},
|
|
318
|
+
[setState, onChange]
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
const handleOnFocus = useCallback(
|
|
322
|
+
(event) => {
|
|
323
|
+
onFocus && onFocus(event);
|
|
324
|
+
setState({ isFilterInputFocused: true });
|
|
325
|
+
},
|
|
326
|
+
[setState, onFocus]
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
const handleOnBlur = useCallback(
|
|
330
|
+
(event) => {
|
|
331
|
+
onBlur && onBlur(event);
|
|
332
|
+
setState({ isFilterInputFocused: false });
|
|
333
|
+
},
|
|
334
|
+
[setState, onBlur]
|
|
315
335
|
);
|
|
316
336
|
|
|
317
337
|
return (
|
|
318
|
-
<Input
|
|
338
|
+
<Input
|
|
339
|
+
{...props}
|
|
340
|
+
value={state.filterQuery}
|
|
341
|
+
onChange={handleOnChange}
|
|
342
|
+
onFocus={handleOnFocus}
|
|
343
|
+
onBlur={handleOnBlur}
|
|
344
|
+
/>
|
|
319
345
|
);
|
|
320
346
|
};
|
|
321
347
|
|
|
@@ -364,6 +390,7 @@ export const Menu = ({
|
|
|
364
390
|
selectionIndex: 0,
|
|
365
391
|
filterQuery: "",
|
|
366
392
|
filteredItems: null,
|
|
393
|
+
isFilterInputFocused: false,
|
|
367
394
|
});
|
|
368
395
|
const selectCallbacks = useRef<(?(() => void))[]>([]);
|
|
369
396
|
const menuRef = useRef(null);
|
|
@@ -203,3 +203,23 @@ export const MenuWithCheckboxes = (props) => {
|
|
|
203
203
|
</Menu>
|
|
204
204
|
);
|
|
205
205
|
};
|
|
206
|
+
|
|
207
|
+
// Specifically testing that icons with a color inverse when active like the text does.
|
|
208
|
+
export const MenuWithIcons = (props) => {
|
|
209
|
+
return (
|
|
210
|
+
<Menu width="200px" {...props}>
|
|
211
|
+
<Menu.Item key="positive" onClick={() => alert("positive")}>
|
|
212
|
+
<Icon name="flat-positive-sentiment" mr={200} color="blue.600" />
|
|
213
|
+
Positive
|
|
214
|
+
</Menu.Item>
|
|
215
|
+
<Menu.Item key="negative" onClick={() => alert("negative")}>
|
|
216
|
+
<Icon name="flat-negative-sentiment" mr={200} color="red.500" />
|
|
217
|
+
Negative
|
|
218
|
+
</Menu.Item>
|
|
219
|
+
<Menu.Item key="neutral" onClick={() => alert("neutral")}>
|
|
220
|
+
<Icon name="flat-neutral-sentiment" mr={200} />
|
|
221
|
+
Neutral
|
|
222
|
+
</Menu.Item>
|
|
223
|
+
</Menu>
|
|
224
|
+
);
|
|
225
|
+
};
|
package/__flow__/Menu/styles.js
CHANGED
|
@@ -41,6 +41,10 @@ export const MenuItemContainer = styled<
|
|
|
41
41
|
css`
|
|
42
42
|
color: ${(props) => props.theme.colors.text.inverse};
|
|
43
43
|
background-color: ${props.theme.colors.listItem.background.selected};
|
|
44
|
+
|
|
45
|
+
.Icon-svg {
|
|
46
|
+
color: ${(props) => props.theme.colors.text.inverse};
|
|
47
|
+
}
|
|
44
48
|
`}
|
|
45
49
|
|
|
46
50
|
${(props) =>
|