@khanacademy/wonder-blocks-button 2.10.2 → 2.11.0

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.
@@ -21,8 +21,8 @@ exports[`wonder-blocks-button example 1 1`] = `
21
21
  }
22
22
  >
23
23
  <button
24
+ aria-disabled={false}
24
25
  className=""
25
- disabled={false}
26
26
  onBlur={[Function]}
27
27
  onClick={[Function]}
28
28
  onDragStart={[Function]}
@@ -94,8 +94,8 @@ exports[`wonder-blocks-button example 1 1`] = `
94
94
  </span>
95
95
  </button>
96
96
  <button
97
+ aria-disabled={false}
97
98
  className=""
98
- disabled={false}
99
99
  onBlur={[Function]}
100
100
  onClick={[Function]}
101
101
  onDragStart={[Function]}
@@ -170,8 +170,8 @@ exports[`wonder-blocks-button example 1 1`] = `
170
170
  </span>
171
171
  </button>
172
172
  <button
173
+ aria-disabled={false}
173
174
  className=""
174
- disabled={false}
175
175
  onBlur={[Function]}
176
176
  onClick={[Function]}
177
177
  onDragStart={[Function]}
@@ -267,8 +267,8 @@ exports[`wonder-blocks-button example 2 1`] = `
267
267
  }
268
268
  >
269
269
  <button
270
+ aria-disabled={false}
270
271
  className=""
271
- disabled={false}
272
272
  onBlur={[Function]}
273
273
  onClick={[Function]}
274
274
  onDragStart={[Function]}
@@ -340,8 +340,8 @@ exports[`wonder-blocks-button example 2 1`] = `
340
340
  </span>
341
341
  </button>
342
342
  <button
343
+ aria-disabled={false}
343
344
  className=""
344
- disabled={false}
345
345
  onBlur={[Function]}
346
346
  onClick={[Function]}
347
347
  onDragStart={[Function]}
@@ -416,8 +416,8 @@ exports[`wonder-blocks-button example 2 1`] = `
416
416
  </span>
417
417
  </button>
418
418
  <button
419
+ aria-disabled={false}
419
420
  className=""
420
- disabled={false}
421
421
  onBlur={[Function]}
422
422
  onClick={[Function]}
423
423
  onDragStart={[Function]}
@@ -513,8 +513,8 @@ exports[`wonder-blocks-button example 3 1`] = `
513
513
  }
514
514
  >
515
515
  <button
516
+ aria-disabled={true}
516
517
  className=""
517
- disabled={true}
518
518
  onBlur={[Function]}
519
519
  onClick={[Function]}
520
520
  onDragStart={[Function]}
@@ -535,7 +535,7 @@ exports[`wonder-blocks-button example 3 1`] = `
535
535
  "border": 0,
536
536
  },
537
537
  ":focus": Object {
538
- "WebkitTapHighlightColor": "rgba(0,0,0,0)",
538
+ "boxShadow": "0 0 0 1px #ffffff, 0 0 0 3px rgba(33,36,44,0.32)",
539
539
  },
540
540
  "alignItems": "center",
541
541
  "background": "rgba(33,36,44,0.32)",
@@ -560,7 +560,7 @@ exports[`wonder-blocks-button example 3 1`] = `
560
560
  "userSelect": "none",
561
561
  }
562
562
  }
563
- tabIndex={-1}
563
+ tabIndex={0}
564
564
  type="button"
565
565
  >
566
566
  <span
@@ -586,8 +586,8 @@ exports[`wonder-blocks-button example 3 1`] = `
586
586
  </span>
587
587
  </button>
588
588
  <button
589
+ aria-disabled={true}
589
590
  className=""
590
- disabled={true}
591
591
  onBlur={[Function]}
592
592
  onClick={[Function]}
593
593
  onDragStart={[Function]}
@@ -608,7 +608,10 @@ exports[`wonder-blocks-button example 3 1`] = `
608
608
  "border": 0,
609
609
  },
610
610
  ":focus": Object {
611
- "WebkitTapHighlightColor": "rgba(0,0,0,0)",
611
+ "borderColor": "rgba(33,36,44,0.32)",
612
+ "borderWidth": 2,
613
+ "paddingLeft": 15,
614
+ "paddingRight": 15,
612
615
  },
613
616
  "alignItems": "center",
614
617
  "background": "none",
@@ -636,7 +639,7 @@ exports[`wonder-blocks-button example 3 1`] = `
636
639
  "userSelect": "none",
637
640
  }
638
641
  }
639
- tabIndex={-1}
642
+ tabIndex={0}
640
643
  type="button"
641
644
  >
642
645
  <span
@@ -662,8 +665,8 @@ exports[`wonder-blocks-button example 3 1`] = `
662
665
  </span>
663
666
  </button>
664
667
  <button
668
+ aria-disabled={true}
665
669
  className=""
666
- disabled={true}
667
670
  onBlur={[Function]}
668
671
  onClick={[Function]}
669
672
  onDragStart={[Function]}
@@ -709,7 +712,7 @@ exports[`wonder-blocks-button example 3 1`] = `
709
712
  "userSelect": "none",
710
713
  }
711
714
  }
712
- tabIndex={-1}
715
+ tabIndex={0}
713
716
  type="button"
714
717
  >
715
718
  <span
@@ -760,8 +763,8 @@ exports[`wonder-blocks-button example 4 1`] = `
760
763
  }
761
764
  >
762
765
  <button
766
+ aria-disabled={false}
763
767
  className=""
764
- disabled={false}
765
768
  onBlur={[Function]}
766
769
  onClick={[Function]}
767
770
  onDragStart={[Function]}
@@ -833,8 +836,8 @@ exports[`wonder-blocks-button example 4 1`] = `
833
836
  </span>
834
837
  </button>
835
838
  <button
839
+ aria-disabled={false}
836
840
  className=""
837
- disabled={false}
838
841
  onBlur={[Function]}
839
842
  onClick={[Function]}
840
843
  onDragStart={[Function]}
@@ -909,8 +912,8 @@ exports[`wonder-blocks-button example 4 1`] = `
909
912
  </span>
910
913
  </button>
911
914
  <button
915
+ aria-disabled={false}
912
916
  className=""
913
- disabled={false}
914
917
  onBlur={[Function]}
915
918
  onClick={[Function]}
916
919
  onDragStart={[Function]}
@@ -983,8 +986,8 @@ exports[`wonder-blocks-button example 4 1`] = `
983
986
  </span>
984
987
  </button>
985
988
  <button
989
+ aria-disabled={true}
986
990
  className=""
987
- disabled={true}
988
991
  onBlur={[Function]}
989
992
  onClick={[Function]}
990
993
  onDragStart={[Function]}
@@ -1005,7 +1008,7 @@ exports[`wonder-blocks-button example 4 1`] = `
1005
1008
  "border": 0,
1006
1009
  },
1007
1010
  ":focus": Object {
1008
- "WebkitTapHighlightColor": "rgba(0,0,0,0)",
1011
+ "boxShadow": "0 0 0 1px rgba(33,36,44,0.32), 0 0 0 3px #b5cefb",
1009
1012
  },
1010
1013
  "alignItems": "center",
1011
1014
  "background": "#b5cefb",
@@ -1030,7 +1033,7 @@ exports[`wonder-blocks-button example 4 1`] = `
1030
1033
  "userSelect": "none",
1031
1034
  }
1032
1035
  }
1033
- tabIndex={-1}
1036
+ tabIndex={0}
1034
1037
  type="button"
1035
1038
  >
1036
1039
  <span
@@ -1056,8 +1059,8 @@ exports[`wonder-blocks-button example 4 1`] = `
1056
1059
  </span>
1057
1060
  </button>
1058
1061
  <button
1062
+ aria-disabled={true}
1059
1063
  className=""
1060
- disabled={true}
1061
1064
  onBlur={[Function]}
1062
1065
  onClick={[Function]}
1063
1066
  onDragStart={[Function]}
@@ -1078,7 +1081,10 @@ exports[`wonder-blocks-button example 4 1`] = `
1078
1081
  "border": 0,
1079
1082
  },
1080
1083
  ":focus": Object {
1081
- "WebkitTapHighlightColor": "rgba(0,0,0,0)",
1084
+ "borderColor": "rgba(255,255,255,0.50)",
1085
+ "borderWidth": 2,
1086
+ "paddingLeft": 15,
1087
+ "paddingRight": 15,
1082
1088
  },
1083
1089
  "alignItems": "center",
1084
1090
  "background": "none",
@@ -1106,7 +1112,7 @@ exports[`wonder-blocks-button example 4 1`] = `
1106
1112
  "userSelect": "none",
1107
1113
  }
1108
1114
  }
1109
- tabIndex={-1}
1115
+ tabIndex={0}
1110
1116
  type="button"
1111
1117
  >
1112
1118
  <span
@@ -1132,8 +1138,8 @@ exports[`wonder-blocks-button example 4 1`] = `
1132
1138
  </span>
1133
1139
  </button>
1134
1140
  <button
1141
+ aria-disabled={true}
1135
1142
  className=""
1136
- disabled={true}
1137
1143
  onBlur={[Function]}
1138
1144
  onClick={[Function]}
1139
1145
  onDragStart={[Function]}
@@ -1179,7 +1185,7 @@ exports[`wonder-blocks-button example 4 1`] = `
1179
1185
  "userSelect": "none",
1180
1186
  }
1181
1187
  }
1182
- tabIndex={-1}
1188
+ tabIndex={0}
1183
1189
  type="button"
1184
1190
  >
1185
1191
  <span
@@ -1249,8 +1255,8 @@ exports[`wonder-blocks-button example 5 1`] = `
1249
1255
  }
1250
1256
  >
1251
1257
  <button
1258
+ aria-disabled={false}
1252
1259
  className=""
1253
- disabled={false}
1254
1260
  onBlur={[Function]}
1255
1261
  onClick={[Function]}
1256
1262
  onDragStart={[Function]}
@@ -1322,8 +1328,8 @@ exports[`wonder-blocks-button example 5 1`] = `
1322
1328
  </span>
1323
1329
  </button>
1324
1330
  <button
1331
+ aria-disabled={false}
1325
1332
  className=""
1326
- disabled={false}
1327
1333
  onBlur={[Function]}
1328
1334
  onClick={[Function]}
1329
1335
  onDragStart={[Function]}
@@ -1398,8 +1404,8 @@ exports[`wonder-blocks-button example 5 1`] = `
1398
1404
  </span>
1399
1405
  </button>
1400
1406
  <button
1407
+ aria-disabled={false}
1401
1408
  className=""
1402
- disabled={false}
1403
1409
  onBlur={[Function]}
1404
1410
  onClick={[Function]}
1405
1411
  onDragStart={[Function]}
@@ -1493,8 +1499,8 @@ exports[`wonder-blocks-button example 5 1`] = `
1493
1499
  }
1494
1500
  >
1495
1501
  <button
1502
+ aria-disabled={false}
1496
1503
  className=""
1497
- disabled={false}
1498
1504
  onBlur={[Function]}
1499
1505
  onClick={[Function]}
1500
1506
  onDragStart={[Function]}
@@ -1566,8 +1572,8 @@ exports[`wonder-blocks-button example 5 1`] = `
1566
1572
  </span>
1567
1573
  </button>
1568
1574
  <button
1575
+ aria-disabled={false}
1569
1576
  className=""
1570
- disabled={false}
1571
1577
  onBlur={[Function]}
1572
1578
  onClick={[Function]}
1573
1579
  onDragStart={[Function]}
@@ -1642,8 +1648,8 @@ exports[`wonder-blocks-button example 5 1`] = `
1642
1648
  </span>
1643
1649
  </button>
1644
1650
  <button
1651
+ aria-disabled={false}
1645
1652
  className=""
1646
- disabled={false}
1647
1653
  onBlur={[Function]}
1648
1654
  onClick={[Function]}
1649
1655
  onDragStart={[Function]}
@@ -1737,8 +1743,8 @@ exports[`wonder-blocks-button example 5 1`] = `
1737
1743
  }
1738
1744
  >
1739
1745
  <button
1746
+ aria-disabled={false}
1740
1747
  className=""
1741
- disabled={false}
1742
1748
  onBlur={[Function]}
1743
1749
  onClick={[Function]}
1744
1750
  onDragStart={[Function]}
@@ -1810,8 +1816,8 @@ exports[`wonder-blocks-button example 5 1`] = `
1810
1816
  </span>
1811
1817
  </button>
1812
1818
  <button
1819
+ aria-disabled={false}
1813
1820
  className=""
1814
- disabled={false}
1815
1821
  onBlur={[Function]}
1816
1822
  onClick={[Function]}
1817
1823
  onDragStart={[Function]}
@@ -1886,8 +1892,8 @@ exports[`wonder-blocks-button example 5 1`] = `
1886
1892
  </span>
1887
1893
  </button>
1888
1894
  <button
1895
+ aria-disabled={false}
1889
1896
  className=""
1890
- disabled={false}
1891
1897
  onBlur={[Function]}
1892
1898
  onClick={[Function]}
1893
1899
  onDragStart={[Function]}
@@ -1984,9 +1990,9 @@ exports[`wonder-blocks-button example 6 1`] = `
1984
1990
  }
1985
1991
  >
1986
1992
  <button
1993
+ aria-disabled={true}
1987
1994
  aria-label="loading"
1988
1995
  className=""
1989
- disabled={true}
1990
1996
  onBlur={[Function]}
1991
1997
  onClick={[Function]}
1992
1998
  onDragStart={[Function]}
@@ -2007,7 +2013,7 @@ exports[`wonder-blocks-button example 6 1`] = `
2007
2013
  "border": 0,
2008
2014
  },
2009
2015
  ":focus": Object {
2010
- "WebkitTapHighlightColor": "rgba(0,0,0,0)",
2016
+ "boxShadow": "0 0 0 1px #ffffff, 0 0 0 3px rgba(33,36,44,0.32)",
2011
2017
  },
2012
2018
  "alignItems": "center",
2013
2019
  "background": "rgba(33,36,44,0.32)",
@@ -2032,7 +2038,7 @@ exports[`wonder-blocks-button example 6 1`] = `
2032
2038
  "userSelect": "none",
2033
2039
  }
2034
2040
  }
2035
- tabIndex={-1}
2041
+ tabIndex={0}
2036
2042
  type="button"
2037
2043
  >
2038
2044
  <span
@@ -2112,9 +2118,9 @@ exports[`wonder-blocks-button example 6 1`] = `
2112
2118
  </div>
2113
2119
  </button>
2114
2120
  <button
2121
+ aria-disabled={true}
2115
2122
  aria-label="loading"
2116
2123
  className=""
2117
- disabled={true}
2118
2124
  onBlur={[Function]}
2119
2125
  onClick={[Function]}
2120
2126
  onDragStart={[Function]}
@@ -2135,7 +2141,7 @@ exports[`wonder-blocks-button example 6 1`] = `
2135
2141
  "border": 0,
2136
2142
  },
2137
2143
  ":focus": Object {
2138
- "WebkitTapHighlightColor": "rgba(0,0,0,0)",
2144
+ "boxShadow": "0 0 0 1px #ffffff, 0 0 0 3px rgba(33,36,44,0.32)",
2139
2145
  },
2140
2146
  "alignItems": "center",
2141
2147
  "background": "rgba(33,36,44,0.32)",
@@ -2160,7 +2166,7 @@ exports[`wonder-blocks-button example 6 1`] = `
2160
2166
  "userSelect": "none",
2161
2167
  }
2162
2168
  }
2163
- tabIndex={-1}
2169
+ tabIndex={0}
2164
2170
  type="button"
2165
2171
  >
2166
2172
  <span
@@ -2240,9 +2246,9 @@ exports[`wonder-blocks-button example 6 1`] = `
2240
2246
  </div>
2241
2247
  </button>
2242
2248
  <button
2249
+ aria-disabled={true}
2243
2250
  aria-label="loading"
2244
2251
  className=""
2245
- disabled={true}
2246
2252
  onBlur={[Function]}
2247
2253
  onClick={[Function]}
2248
2254
  onDragStart={[Function]}
@@ -2263,7 +2269,7 @@ exports[`wonder-blocks-button example 6 1`] = `
2263
2269
  "border": 0,
2264
2270
  },
2265
2271
  ":focus": Object {
2266
- "WebkitTapHighlightColor": "rgba(0,0,0,0)",
2272
+ "boxShadow": "0 0 0 1px #ffffff, 0 0 0 3px rgba(33,36,44,0.32)",
2267
2273
  },
2268
2274
  "alignItems": "center",
2269
2275
  "background": "rgba(33,36,44,0.32)",
@@ -2288,7 +2294,7 @@ exports[`wonder-blocks-button example 6 1`] = `
2288
2294
  "userSelect": "none",
2289
2295
  }
2290
2296
  }
2291
- tabIndex={-1}
2297
+ tabIndex={0}
2292
2298
  type="button"
2293
2299
  >
2294
2300
  <span
@@ -2459,8 +2465,8 @@ exports[`wonder-blocks-button example 7 1`] = `
2459
2465
  </span>
2460
2466
  </a>
2461
2467
  <button
2468
+ aria-disabled={false}
2462
2469
  className=""
2463
- disabled={false}
2464
2470
  onBlur={[Function]}
2465
2471
  onClick={[Function]}
2466
2472
  onDragStart={[Function]}
@@ -3354,8 +3360,8 @@ exports[`wonder-blocks-button example 12 1`] = `
3354
3360
  }
3355
3361
  >
3356
3362
  <button
3363
+ aria-disabled={false}
3357
3364
  className=""
3358
- disabled={false}
3359
3365
  onBlur={[Function]}
3360
3366
  onClick={[Function]}
3361
3367
  onDragStart={[Function]}
@@ -3447,8 +3453,8 @@ exports[`wonder-blocks-button example 12 1`] = `
3447
3453
  </span>
3448
3454
  </button>
3449
3455
  <button
3456
+ aria-disabled={false}
3450
3457
  className=""
3451
- disabled={false}
3452
3458
  onBlur={[Function]}
3453
3459
  onClick={[Function]}
3454
3460
  onDragStart={[Function]}
@@ -3543,8 +3549,8 @@ exports[`wonder-blocks-button example 12 1`] = `
3543
3549
  </span>
3544
3550
  </button>
3545
3551
  <button
3552
+ aria-disabled={false}
3546
3553
  className=""
3547
- disabled={false}
3548
3554
  onBlur={[Function]}
3549
3555
  onClick={[Function]}
3550
3556
  onDragStart={[Function]}
@@ -3658,8 +3664,8 @@ exports[`wonder-blocks-button example 12 1`] = `
3658
3664
  }
3659
3665
  >
3660
3666
  <button
3667
+ aria-disabled={false}
3661
3668
  className=""
3662
- disabled={false}
3663
3669
  onBlur={[Function]}
3664
3670
  onClick={[Function]}
3665
3671
  onDragStart={[Function]}
@@ -3752,8 +3758,8 @@ exports[`wonder-blocks-button example 12 1`] = `
3752
3758
  </span>
3753
3759
  </button>
3754
3760
  <button
3761
+ aria-disabled={false}
3755
3762
  className=""
3756
- disabled={false}
3757
3763
  onBlur={[Function]}
3758
3764
  onClick={[Function]}
3759
3765
  onDragStart={[Function]}
@@ -3849,8 +3855,8 @@ exports[`wonder-blocks-button example 12 1`] = `
3849
3855
  </span>
3850
3856
  </button>
3851
3857
  <button
3858
+ aria-disabled={false}
3852
3859
  className=""
3853
- disabled={false}
3854
3860
  onBlur={[Function]}
3855
3861
  onClick={[Function]}
3856
3862
  onDragStart={[Function]}
@@ -3971,8 +3977,8 @@ exports[`wonder-blocks-button example 13 1`] = `
3971
3977
  onSubmit={[Function]}
3972
3978
  >
3973
3979
  <button
3980
+ aria-disabled={false}
3974
3981
  className=""
3975
- disabled={false}
3976
3982
  onBlur={[Function]}
3977
3983
  onClick={[Function]}
3978
3984
  onDragStart={[Function]}
@@ -4067,8 +4073,8 @@ exports[`wonder-blocks-button example 14 1`] = `
4067
4073
  }
4068
4074
  >
4069
4075
  <button
4076
+ aria-disabled={false}
4070
4077
  className=""
4071
- disabled={false}
4072
4078
  onBlur={[Function]}
4073
4079
  onClick={[Function]}
4074
4080
  onDragStart={[Function]}
@@ -4181,8 +4187,8 @@ exports[`wonder-blocks-button example 15 1`] = `
4181
4187
  }
4182
4188
  >
4183
4189
  <button
4190
+ aria-disabled={false}
4184
4191
  className=""
4185
- disabled={false}
4186
4192
  onBlur={[Function]}
4187
4193
  onClick={[Function]}
4188
4194
  onDragStart={[Function]}
@@ -4293,8 +4299,8 @@ exports[`wonder-blocks-button example 15 1`] = `
4293
4299
  }
4294
4300
  >
4295
4301
  <button
4302
+ aria-disabled={false}
4296
4303
  className=""
4297
- disabled={false}
4298
4304
  onBlur={[Function]}
4299
4305
  onClick={[Function]}
4300
4306
  onDragStart={[Function]}
@@ -4389,8 +4395,8 @@ exports[`wonder-blocks-button example 16 1`] = `
4389
4395
  }
4390
4396
  >
4391
4397
  <button
4398
+ aria-disabled={false}
4392
4399
  className=""
4393
- disabled={false}
4394
4400
  onBlur={[Function]}
4395
4401
  onClick={[Function]}
4396
4402
  onDragStart={[Function]}
@@ -4466,8 +4472,8 @@ exports[`wonder-blocks-button example 16 1`] = `
4466
4472
  </span>
4467
4473
  </button>
4468
4474
  <button
4475
+ aria-disabled={false}
4469
4476
  className=""
4470
- disabled={false}
4471
4477
  onBlur={[Function]}
4472
4478
  onClick={[Function]}
4473
4479
  onDragStart={[Function]}
@@ -4564,8 +4570,8 @@ exports[`wonder-blocks-button example 17 1`] = `
4564
4570
  }
4565
4571
  >
4566
4572
  <button
4573
+ aria-disabled={false}
4567
4574
  className=""
4568
- disabled={false}
4569
4575
  onBlur={[Function]}
4570
4576
  onClick={[Function]}
4571
4577
  onDragStart={[Function]}
@@ -4641,8 +4647,8 @@ exports[`wonder-blocks-button example 17 1`] = `
4641
4647
  </span>
4642
4648
  </button>
4643
4649
  <button
4650
+ aria-disabled={false}
4644
4651
  className=""
4645
- disabled={false}
4646
4652
  onBlur={[Function]}
4647
4653
  onClick={[Function]}
4648
4654
  onDragStart={[Function]}
@@ -4757,8 +4763,8 @@ exports[`wonder-blocks-button example 18 1`] = `
4757
4763
  }
4758
4764
  >
4759
4765
  <button
4766
+ aria-disabled={false}
4760
4767
  className=""
4761
- disabled={false}
4762
4768
  onBlur={[Function]}
4763
4769
  onClick={[Function]}
4764
4770
  onDragStart={[Function]}
@@ -4831,8 +4837,8 @@ exports[`wonder-blocks-button example 18 1`] = `
4831
4837
  </span>
4832
4838
  </button>
4833
4839
  <button
4840
+ aria-disabled={false}
4834
4841
  className=""
4835
- disabled={false}
4836
4842
  onBlur={[Function]}
4837
4843
  onClick={[Function]}
4838
4844
  onDragStart={[Function]}
@@ -4927,9 +4933,9 @@ exports[`wonder-blocks-button example 19 1`] = `
4927
4933
  }
4928
4934
  >
4929
4935
  <button
4936
+ aria-disabled={false}
4930
4937
  aria-label=""
4931
4938
  className=""
4932
- disabled={false}
4933
4939
  onBlur={[Function]}
4934
4940
  onClick={[Function]}
4935
4941
  onDragStart={[Function]}
@@ -1,7 +1,9 @@
1
1
  // @flow
2
2
  import * as React from "react";
3
3
  import {MemoryRouter, Route, Switch} from "react-router-dom";
4
+ import {render, screen} from "@testing-library/react";
4
5
  import {mount} from "enzyme";
6
+ import "jest-enzyme";
5
7
 
6
8
  import Button from "../button.js";
7
9
 
@@ -785,6 +787,56 @@ describe("Button", () => {
785
787
  });
786
788
  });
787
789
 
790
+ describe("button focus", () => {
791
+ test("primary button can have focus", async () => {
792
+ // Arrange
793
+ render(<Button testId={"button-focus-test"}>Label</Button>);
794
+
795
+ // Act
796
+ const button = screen.getByTestId("button-focus-test");
797
+ button.focus();
798
+
799
+ // Assert
800
+ expect(button).toHaveFocus();
801
+ });
802
+
803
+ test("primary button can have focus when disabled", async () => {
804
+ // Arrange
805
+ render(
806
+ <Button disabled={true} testId={"button-focus-test"}>
807
+ Label
808
+ </Button>,
809
+ );
810
+
811
+ // Act
812
+ const button = screen.getByTestId("button-focus-test");
813
+ button.focus();
814
+
815
+ // Assert
816
+ expect(button).toHaveFocus();
817
+ });
818
+
819
+ test("tertiary button can have focus when disabled", async () => {
820
+ // Arrange
821
+ render(
822
+ <Button
823
+ disabled={true}
824
+ testId={"button-focus-test"}
825
+ kind="tertiary"
826
+ >
827
+ Label
828
+ </Button>,
829
+ );
830
+
831
+ // Act
832
+ const button = screen.getByTestId("button-focus-test");
833
+ button.focus();
834
+
835
+ // Assert
836
+ expect(button).toHaveFocus();
837
+ });
838
+ });
839
+
788
840
  describe("type='submit'", () => {
789
841
  test("submit button within form via click", () => {
790
842
  // Arrange
@@ -162,7 +162,7 @@ export default class ButtonCore extends React.Component<Props> {
162
162
  <StyledButton
163
163
  type={type || "button"}
164
164
  {...commonProps}
165
- disabled={disabled}
165
+ aria-disabled={disabled}
166
166
  >
167
167
  {contents}
168
168
  </StyledButton>
@@ -291,6 +291,11 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
291
291
  background: light ? fadedColor : offBlack32,
292
292
  color: light ? color : white64,
293
293
  cursor: "default",
294
+ ":focus": {
295
+ boxShadow: `0 0 0 1px ${
296
+ light ? offBlack32 : white
297
+ }, 0 0 0 3px ${light ? fadedColor : offBlack32}`,
298
+ },
294
299
  },
295
300
  };
296
301
  } else if (kind === "secondary") {
@@ -318,6 +323,8 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
318
323
  color: light ? fadedColor : activeColor,
319
324
  borderColor: light ? fadedColor : activeColor,
320
325
  borderWidth: 2,
326
+ // We need to reduce padding to offset the difference
327
+ // caused by the border becoming thicker on focus.
321
328
  // The left padding for the button with icon should have 4px
322
329
  // less padding
323
330
  paddingLeft: iconWidth ? padding - 5 : padding - 1,
@@ -327,9 +334,20 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
327
334
  color: light ? white50 : offBlack32,
328
335
  borderColor: light ? fadedColor : offBlack32,
329
336
  cursor: "default",
337
+ ":focus": {
338
+ borderColor: light ? white50 : offBlack32,
339
+ borderWidth: 2,
340
+ // We need to reduce padding to offset the difference
341
+ // caused by the border becoming thicker on focus.
342
+ // The left padding for the button with icon should have 4px
343
+ // less padding
344
+ paddingLeft: iconWidth ? padding - 5 : padding - 1,
345
+ paddingRight: padding - 1,
346
+ },
330
347
  },
331
348
  };
332
349
  } else if (kind === "tertiary") {
350
+ // TODO(FEI-4229): Make tertiary buttons focusable
333
351
  newStyles = {
334
352
  default: {
335
353
  background: "none",