@wordpress/components 28.4.0 → 28.5.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.
Files changed (250) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/build/autocomplete/autocompleter-ui.js +2 -0
  3. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  4. package/build/base-control/styles/base-control-styles.js +8 -8
  5. package/build/base-control/styles/base-control-styles.js.map +1 -1
  6. package/build/border-control/styles.js +18 -24
  7. package/build/border-control/styles.js.map +1 -1
  8. package/build/color-palette/index.js +1 -1
  9. package/build/color-palette/index.js.map +1 -1
  10. package/build/custom-select-control/index.js +37 -14
  11. package/build/custom-select-control/index.js.map +1 -1
  12. package/build/custom-select-control/types.js.map +1 -1
  13. package/build/custom-select-control-v2/styles.js +9 -9
  14. package/build/custom-select-control-v2/styles.js.map +1 -1
  15. package/build/date-time/index.js +0 -7
  16. package/build/date-time/index.js.map +1 -1
  17. package/build/date-time/time/index.js +66 -38
  18. package/build/date-time/time/index.js.map +1 -1
  19. package/build/date-time/time/styles.js +11 -11
  20. package/build/date-time/time/styles.js.map +1 -1
  21. package/build/date-time/{time-input → time/time-input}/index.js +7 -7
  22. package/build/date-time/time/time-input/index.js.map +1 -0
  23. package/build/dropdown-menu-v2/styles.js +14 -14
  24. package/build/dropdown-menu-v2/styles.js.map +1 -1
  25. package/build/form-toggle/index.js +24 -24
  26. package/build/form-toggle/index.js.map +1 -1
  27. package/build/guide/index.js +2 -0
  28. package/build/guide/index.js.map +1 -1
  29. package/build/heading/types.js.map +1 -1
  30. package/build/modal/index.js +18 -11
  31. package/build/modal/index.js.map +1 -1
  32. package/build/query-controls/index.js +1 -1
  33. package/build/query-controls/index.js.map +1 -1
  34. package/build/radio-control/index.js +35 -8
  35. package/build/radio-control/index.js.map +1 -1
  36. package/build/radio-control/types.js.map +1 -1
  37. package/build/select-control/index.js +20 -8
  38. package/build/select-control/index.js.map +1 -1
  39. package/build/select-control/types.js.map +1 -1
  40. package/build/text-control/index.js +1 -0
  41. package/build/text-control/index.js.map +1 -1
  42. package/build/toggle-control/index.js +27 -25
  43. package/build/toggle-control/index.js.map +1 -1
  44. package/build/toggle-group-control/toggle-group-control/component.js +6 -1
  45. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  46. package/build/toggle-group-control/toggle-group-control-option/component.js +6 -1
  47. package/build/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
  48. package/build/toggle-group-control/toggle-group-control-option-icon/component.js +14 -14
  49. package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
  50. package/build/tooltip/index.js +12 -1
  51. package/build/tooltip/index.js.map +1 -1
  52. package/build/tree-select/index.js +1 -2
  53. package/build/tree-select/index.js.map +1 -1
  54. package/build/utils/config-values.js +6 -0
  55. package/build/utils/config-values.js.map +1 -1
  56. package/build-module/autocomplete/autocompleter-ui.js +2 -0
  57. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  58. package/build-module/base-control/styles/base-control-styles.js +8 -8
  59. package/build-module/base-control/styles/base-control-styles.js.map +1 -1
  60. package/build-module/border-control/styles.js +13 -23
  61. package/build-module/border-control/styles.js.map +1 -1
  62. package/build-module/color-palette/index.js +1 -1
  63. package/build-module/color-palette/index.js.map +1 -1
  64. package/build-module/custom-select-control/index.js +38 -14
  65. package/build-module/custom-select-control/index.js.map +1 -1
  66. package/build-module/custom-select-control/types.js.map +1 -1
  67. package/build-module/custom-select-control-v2/styles.js +9 -9
  68. package/build-module/custom-select-control-v2/styles.js.map +1 -1
  69. package/build-module/date-time/index.js +1 -2
  70. package/build-module/date-time/index.js.map +1 -1
  71. package/build-module/date-time/time/index.js +66 -38
  72. package/build-module/date-time/time/index.js.map +1 -1
  73. package/build-module/date-time/time/styles.js +11 -11
  74. package/build-module/date-time/time/styles.js.map +1 -1
  75. package/build-module/date-time/{time-input → time/time-input}/index.js +7 -7
  76. package/build-module/date-time/time/time-input/index.js.map +1 -0
  77. package/build-module/dropdown-menu-v2/styles.js +14 -14
  78. package/build-module/dropdown-menu-v2/styles.js.map +1 -1
  79. package/build-module/form-toggle/index.js +23 -22
  80. package/build-module/form-toggle/index.js.map +1 -1
  81. package/build-module/guide/index.js +2 -0
  82. package/build-module/guide/index.js.map +1 -1
  83. package/build-module/heading/types.js.map +1 -1
  84. package/build-module/modal/index.js +17 -11
  85. package/build-module/modal/index.js.map +1 -1
  86. package/build-module/query-controls/index.js +1 -1
  87. package/build-module/query-controls/index.js.map +1 -1
  88. package/build-module/radio-control/index.js +36 -10
  89. package/build-module/radio-control/index.js.map +1 -1
  90. package/build-module/radio-control/types.js.map +1 -1
  91. package/build-module/select-control/index.js +20 -8
  92. package/build-module/select-control/index.js.map +1 -1
  93. package/build-module/select-control/types.js.map +1 -1
  94. package/build-module/text-control/index.js +1 -0
  95. package/build-module/text-control/index.js.map +1 -1
  96. package/build-module/toggle-control/index.js +26 -24
  97. package/build-module/toggle-control/index.js.map +1 -1
  98. package/build-module/toggle-group-control/toggle-group-control/component.js +6 -1
  99. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  100. package/build-module/toggle-group-control/toggle-group-control-option/component.js +6 -1
  101. package/build-module/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
  102. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +14 -14
  103. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
  104. package/build-module/tooltip/index.js +13 -2
  105. package/build-module/tooltip/index.js.map +1 -1
  106. package/build-module/tree-select/index.js +1 -2
  107. package/build-module/tree-select/index.js.map +1 -1
  108. package/build-module/utils/config-values.js +6 -0
  109. package/build-module/utils/config-values.js.map +1 -1
  110. package/build-style/style-rtl.css +60 -24
  111. package/build-style/style.css +60 -24
  112. package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
  113. package/build-types/border-control/styles.d.ts.map +1 -1
  114. package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
  115. package/build-types/color-palette/index.d.ts.map +1 -1
  116. package/build-types/color-palette/styles.d.ts +2 -2
  117. package/build-types/color-picker/styles.d.ts +3 -1
  118. package/build-types/color-picker/styles.d.ts.map +1 -1
  119. package/build-types/custom-select-control/index.d.ts +2 -2
  120. package/build-types/custom-select-control/index.d.ts.map +1 -1
  121. package/build-types/custom-select-control/stories/index.story.d.ts +3 -3
  122. package/build-types/custom-select-control/stories/index.story.d.ts.map +1 -1
  123. package/build-types/custom-select-control/types.d.ts +7 -7
  124. package/build-types/custom-select-control/types.d.ts.map +1 -1
  125. package/build-types/custom-select-control-v2/styles.d.ts +16 -28
  126. package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
  127. package/build-types/date-time/date/styles.d.ts +2 -2
  128. package/build-types/date-time/index.d.ts +1 -2
  129. package/build-types/date-time/index.d.ts.map +1 -1
  130. package/build-types/date-time/stories/time.story.d.ts +5 -0
  131. package/build-types/date-time/stories/time.story.d.ts.map +1 -1
  132. package/build-types/date-time/time/index.d.ts +3 -0
  133. package/build-types/date-time/time/index.d.ts.map +1 -1
  134. package/build-types/date-time/time/styles.d.ts.map +1 -1
  135. package/build-types/date-time/{time-input → time/time-input}/index.d.ts +1 -1
  136. package/build-types/date-time/time/time-input/index.d.ts.map +1 -0
  137. package/build-types/date-time/time/time-input/test/index.d.ts.map +1 -0
  138. package/build-types/dropdown-menu-v2/styles.d.ts +24 -42
  139. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
  140. package/build-types/form-toggle/index.d.ts +2 -5
  141. package/build-types/form-toggle/index.d.ts.map +1 -1
  142. package/build-types/guide/index.d.ts.map +1 -1
  143. package/build-types/heading/component.d.ts +1 -1
  144. package/build-types/heading/types.d.ts +1 -1
  145. package/build-types/heading/types.d.ts.map +1 -1
  146. package/build-types/modal/index.d.ts.map +1 -1
  147. package/build-types/navigation/styles/navigation-styles.d.ts +2 -2
  148. package/build-types/palette-edit/styles.d.ts +2 -2
  149. package/build-types/query-controls/index.d.ts.map +1 -1
  150. package/build-types/radio-control/index.d.ts.map +1 -1
  151. package/build-types/radio-control/stories/index.story.d.ts +1 -0
  152. package/build-types/radio-control/stories/index.story.d.ts.map +1 -1
  153. package/build-types/radio-control/test/index.d.ts +2 -0
  154. package/build-types/radio-control/test/index.d.ts.map +1 -0
  155. package/build-types/radio-control/types.d.ts +4 -0
  156. package/build-types/radio-control/types.d.ts.map +1 -1
  157. package/build-types/select-control/index.d.ts +4 -1
  158. package/build-types/select-control/index.d.ts.map +1 -1
  159. package/build-types/select-control/stories/index.story.d.ts +9 -3
  160. package/build-types/select-control/stories/index.story.d.ts.map +1 -1
  161. package/build-types/select-control/types.d.ts +27 -27
  162. package/build-types/select-control/types.d.ts.map +1 -1
  163. package/build-types/tabs/styles.d.ts +8 -14
  164. package/build-types/tabs/styles.d.ts.map +1 -1
  165. package/build-types/text-control/index.d.ts +1 -0
  166. package/build-types/text-control/index.d.ts.map +1 -1
  167. package/build-types/toggle-control/index.d.ts +3 -9
  168. package/build-types/toggle-control/index.d.ts.map +1 -1
  169. package/build-types/toggle-group-control/toggle-group-control/component.d.ts +6 -1
  170. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  171. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +6 -1
  172. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts.map +1 -1
  173. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +14 -14
  174. package/build-types/tooltip/index.d.ts.map +1 -1
  175. package/build-types/tooltip/test/utils/index.d.ts +1 -5
  176. package/build-types/tooltip/test/utils/index.d.ts.map +1 -1
  177. package/build-types/tree-select/index.d.ts +1 -1
  178. package/build-types/tree-select/index.d.ts.map +1 -1
  179. package/build-types/utils/config-values.d.ts +6 -0
  180. package/package.json +20 -20
  181. package/src/alignment-matrix-control/test/index.tsx +1 -3
  182. package/src/autocomplete/autocompleter-ui.tsx +2 -0
  183. package/src/autocomplete/style.scss +0 -6
  184. package/src/base-control/styles/base-control-styles.ts +1 -1
  185. package/src/border-control/styles.ts +0 -5
  186. package/src/button/stories/e2e/index.story.tsx +103 -21
  187. package/src/button/style.scss +49 -21
  188. package/src/button/test/index.tsx +18 -40
  189. package/src/circular-option-picker/test/index.tsx +1 -4
  190. package/src/color-palette/index.tsx +22 -20
  191. package/src/composite/legacy/test/index.tsx +2 -18
  192. package/src/custom-select-control/index.tsx +55 -25
  193. package/src/custom-select-control/test/index.tsx +47 -30
  194. package/src/custom-select-control/types.ts +7 -7
  195. package/src/custom-select-control-v2/styles.ts +7 -6
  196. package/src/custom-select-control-v2/test/index.tsx +15 -19
  197. package/src/date-time/index.ts +1 -2
  198. package/src/date-time/stories/time.story.tsx +17 -0
  199. package/src/date-time/time/index.tsx +46 -16
  200. package/src/date-time/time/styles.ts +1 -0
  201. package/src/date-time/{time-input → time/time-input}/index.tsx +9 -9
  202. package/src/dropdown-menu-v2/styles.ts +18 -17
  203. package/src/dropdown-menu-v2/test/index.tsx +1 -4
  204. package/src/font-size-picker/test/index.tsx +50 -43
  205. package/src/form-toggle/index.tsx +23 -21
  206. package/src/guide/index.tsx +2 -0
  207. package/src/heading/types.ts +1 -4
  208. package/src/modal/index.tsx +21 -20
  209. package/src/placeholder/style.scss +11 -2
  210. package/src/query-controls/index.tsx +5 -1
  211. package/src/radio-control/index.tsx +48 -7
  212. package/src/radio-control/stories/index.story.tsx +23 -0
  213. package/src/radio-control/style.scss +26 -2
  214. package/src/radio-control/test/index.tsx +274 -0
  215. package/src/radio-control/types.ts +4 -0
  216. package/src/select-control/README.md +8 -1
  217. package/src/select-control/index.tsx +33 -22
  218. package/src/select-control/test/select-control.tsx +148 -4
  219. package/src/select-control/types.ts +70 -65
  220. package/src/tab-panel/test/index.tsx +1 -8
  221. package/src/tabs/test/index.tsx +68 -84
  222. package/src/text-control/README.md +1 -0
  223. package/src/text-control/index.tsx +1 -0
  224. package/src/text-control/style.scss +5 -0
  225. package/src/toggle-control/README.md +9 -0
  226. package/src/toggle-control/index.tsx +25 -22
  227. package/src/toggle-control/style.scss +2 -1
  228. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +6 -6
  229. package/src/toggle-group-control/test/index.tsx +0 -6
  230. package/src/toggle-group-control/toggle-group-control/README.md +13 -1
  231. package/src/toggle-group-control/toggle-group-control/component.tsx +6 -1
  232. package/src/toggle-group-control/toggle-group-control-option/README.md +6 -1
  233. package/src/toggle-group-control/toggle-group-control-option/component.tsx +6 -1
  234. package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
  235. package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +14 -14
  236. package/src/tooltip/index.tsx +15 -2
  237. package/src/tooltip/test/index.tsx +0 -5
  238. package/src/tooltip/test/utils/index.tsx +5 -5
  239. package/src/tree-select/index.tsx +1 -2
  240. package/src/utils/config-values.js +6 -0
  241. package/tsconfig.tsbuildinfo +1 -1
  242. package/build/date-time/time-input/index.js.map +0 -1
  243. package/build-module/date-time/time-input/index.js.map +0 -1
  244. package/build-types/date-time/stories/time-input.story.d.ts +0 -12
  245. package/build-types/date-time/stories/time-input.story.d.ts.map +0 -1
  246. package/build-types/date-time/time-input/index.d.ts.map +0 -1
  247. package/build-types/date-time/time-input/test/index.d.ts.map +0 -1
  248. package/src/date-time/stories/time-input.story.tsx +0 -36
  249. /package/build-types/date-time/{time-input → time/time-input}/test/index.d.ts +0 -0
  250. /package/src/date-time/{time-input → time/time-input}/test/index.tsx +0 -0
@@ -1,3 +1,10 @@
1
+ /**
2
+ * For easier testing of potential regressions, you can use a Button variant matrix
3
+ * available in a special Storybook instance by running `npm run storybook:e2e:dev`.
4
+ *
5
+ * @see https://github.com/WordPress/gutenberg/blob/trunk/test/storybook-playwright/README.md
6
+ */
7
+
1
8
  .components-button {
2
9
  display: inline-flex;
3
10
  text-decoration: none;
@@ -23,16 +30,10 @@
23
30
  }
24
31
 
25
32
  &[aria-expanded="true"],
26
- &:hover {
33
+ &:hover:not(:disabled, [aria-disabled="true"]) {
27
34
  color: $components-color-accent;
28
35
  }
29
36
 
30
- // Unset some hovers, instead of adding :not specificity.
31
- &:disabled:hover,
32
- &[aria-disabled="true"]:hover {
33
- color: initial;
34
- }
35
-
36
37
  // Focus.
37
38
  // See https://github.com/WordPress/gutenberg/issues/13267 for more context on these selectors.
38
39
  &:focus:not(:disabled) {
@@ -80,7 +81,6 @@
80
81
  color: rgba($white, 0.4);
81
82
  background: $components-color-accent;
82
83
  border-color: $components-color-accent;
83
- opacity: 1;
84
84
  outline: none;
85
85
 
86
86
  &:focus:enabled {
@@ -125,7 +125,6 @@
125
125
  color: $gray-600;
126
126
  background: transparent;
127
127
  transform: none;
128
- opacity: 1;
129
128
  }
130
129
  }
131
130
 
@@ -199,17 +198,32 @@
199
198
  &:not(.is-primary):not(.is-secondary):not(.is-tertiary):not(.is-link) {
200
199
  color: $alert-red;
201
200
 
202
- &:hover:not(:disabled) {
201
+ &:hover:not(:disabled, [aria-disabled="true"]) {
203
202
  color: darken($alert-red, 20%);
204
203
  }
205
204
 
206
- &:focus:not(:disabled) {
205
+ &:focus {
207
206
  box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $alert-red;
208
207
  }
209
208
 
210
- &:active:not(:disabled) {
209
+ &:active:not(:disabled, [aria-disabled="true"]) {
211
210
  background: $gray-400;
212
211
  }
212
+
213
+ &:disabled,
214
+ &[aria-disabled="true"] {
215
+ color: $gray-600;
216
+ }
217
+ }
218
+
219
+ &.is-tertiary {
220
+ &:hover:not(:disabled, [aria-disabled="true"]) {
221
+ background: rgba($alert-red, 0.04);
222
+ }
223
+
224
+ &:active:not(:disabled, [aria-disabled="true"]) {
225
+ background: rgba($alert-red, 0.08);
226
+ }
213
227
  }
214
228
  }
215
229
 
@@ -237,6 +251,11 @@
237
251
  &:focus {
238
252
  border-radius: $radius-block-ui;
239
253
  }
254
+
255
+ &:disabled,
256
+ &[aria-disabled="true"] {
257
+ color: $gray-600;
258
+ }
240
259
  }
241
260
 
242
261
  &:not(:disabled, [aria-disabled="true"]):active {
@@ -246,7 +265,7 @@
246
265
  &:disabled,
247
266
  &[aria-disabled="true"] {
248
267
  cursor: default;
249
- opacity: 0.3;
268
+ color: $gray-600;
250
269
  }
251
270
 
252
271
  &.is-busy,
@@ -259,7 +278,6 @@
259
278
  @media (prefers-reduced-motion: reduce) {
260
279
  animation-duration: 0s;
261
280
  }
262
- opacity: 1;
263
281
  background-size: 100px 100%;
264
282
  /* stylelint-disable -- Disable reason: This function call looks nicer when each argument is on its own line. */
265
283
  background-image: linear-gradient(
@@ -325,8 +343,23 @@
325
343
 
326
344
  // Toggled style.
327
345
  &.is-pressed {
328
- color: $components-color-foreground-inverted;
329
- background: $components-color-foreground;
346
+ &,
347
+ &:hover {
348
+ color: $components-color-foreground-inverted;
349
+ &:not(:disabled, [aria-disabled="true"]) {
350
+ background: $components-color-foreground;
351
+ }
352
+ }
353
+
354
+ &:disabled,
355
+ &[aria-disabled="true"] {
356
+ color: $gray-600;
357
+
358
+ &:not(.is-primary):not(.is-secondary):not(.is-tertiary) {
359
+ color: $components-color-foreground-inverted;
360
+ background: $gray-600;
361
+ }
362
+ }
330
363
 
331
364
  &:focus:not(:disabled) {
332
365
  box-shadow: inset 0 0 0 1px $components-color-background, 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
@@ -334,11 +367,6 @@
334
367
  // Windows High Contrast mode will show this outline, but not the box-shadow.
335
368
  outline: 2px solid transparent;
336
369
  }
337
-
338
- &:hover:not(:disabled) {
339
- color: $components-color-foreground-inverted;
340
- background: $components-color-foreground;
341
- }
342
370
  }
343
371
 
344
372
  svg {
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { render, screen } from '@testing-library/react';
5
- import userEvent from '@testing-library/user-event';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
@@ -16,6 +15,7 @@ import { plusCircle } from '@wordpress/icons';
16
15
  import Button from '..';
17
16
  import Tooltip from '../../tooltip';
18
17
  import cleanupTooltip from '../../tooltip/test/utils';
18
+ import { press } from '@ariakit/test';
19
19
 
20
20
  jest.mock( '../../icon', () => () => <div data-testid="test-icon" /> );
21
21
 
@@ -73,12 +73,10 @@ describe( 'Button', () => {
73
73
  } );
74
74
 
75
75
  it( 'should render a button element with has-text when children are passed', async () => {
76
- const user = userEvent.setup();
77
-
78
76
  render( <Button icon={ plusCircle }>Children</Button> );
79
77
 
80
78
  // Move focus to the button
81
- await user.tab();
79
+ await press.Tab();
82
80
 
83
81
  expect( screen.getByRole( 'button' ) ).toHaveClass( 'has-text' );
84
82
  } );
@@ -113,8 +111,6 @@ describe( 'Button', () => {
113
111
  } );
114
112
 
115
113
  it( 'should render correctly as a tooltip anchor', async () => {
116
- const user = userEvent.setup();
117
-
118
114
  render(
119
115
  <>
120
116
  <Tooltip text="Tooltip text">
@@ -128,7 +124,7 @@ describe( 'Button', () => {
128
124
  name: 'Tooltip anchor',
129
125
  } );
130
126
 
131
- await user.tab();
127
+ await press.Tab();
132
128
 
133
129
  expect( anchor ).toHaveFocus();
134
130
 
@@ -138,7 +134,7 @@ describe( 'Button', () => {
138
134
 
139
135
  expect( tooltip ).toBeVisible();
140
136
 
141
- await user.tab();
137
+ await press.Tab();
142
138
 
143
139
  expect(
144
140
  screen.getByRole( 'button', { name: 'Focus me' } )
@@ -152,8 +148,6 @@ describe( 'Button', () => {
152
148
  } );
153
149
 
154
150
  it( 'should render correctly as a tooltip anchor, ignoring its internal tooltip in favour of the external tooltip', async () => {
155
- const user = userEvent.setup();
156
-
157
151
  render(
158
152
  <>
159
153
  <Tooltip text="Tooltip text">
@@ -167,7 +161,7 @@ describe( 'Button', () => {
167
161
  name: 'Button label',
168
162
  } );
169
163
 
170
- await user.tab();
164
+ await press.Tab();
171
165
 
172
166
  expect( anchor ).toHaveFocus();
173
167
 
@@ -184,7 +178,7 @@ describe( 'Button', () => {
184
178
  } )
185
179
  ).not.toBeInTheDocument();
186
180
 
187
- await user.tab();
181
+ await press.Tab();
188
182
 
189
183
  expect(
190
184
  screen.getByRole( 'button', { name: 'Focus me' } )
@@ -198,8 +192,6 @@ describe( 'Button', () => {
198
192
  } );
199
193
 
200
194
  it( 'should not trash the rendered HTML elements when toggling between showing and not showing a tooltip', async () => {
201
- const user = userEvent.setup();
202
-
203
195
  const { rerender } = render(
204
196
  <Button label="Button label">Test button</Button>
205
197
  );
@@ -210,7 +202,7 @@ describe( 'Button', () => {
210
202
 
211
203
  expect( button ).toBeVisible();
212
204
 
213
- await user.tab();
205
+ await press.Tab();
214
206
 
215
207
  expect( button ).toHaveFocus();
216
208
 
@@ -307,14 +299,12 @@ describe( 'Button', () => {
307
299
  } );
308
300
 
309
301
  it( 'should add an aria-label when the label property is used, with Tooltip wrapper', async () => {
310
- const user = userEvent.setup();
311
-
312
302
  render( <Button icon={ plusCircle } label="WordPress" /> );
313
303
 
314
304
  expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
315
305
 
316
306
  // Move focus to the button
317
- await user.tab();
307
+ await press.Tab();
318
308
 
319
309
  expect( screen.getByText( 'WordPress' ) ).toBeVisible();
320
310
  } );
@@ -338,8 +328,6 @@ describe( 'Button', () => {
338
328
  } );
339
329
 
340
330
  it( 'should populate tooltip with label content for buttons without visible labels (no children)', async () => {
341
- const user = userEvent.setup();
342
-
343
331
  render(
344
332
  <Button
345
333
  description="Description text"
@@ -351,16 +339,14 @@ describe( 'Button', () => {
351
339
  expect( screen.queryByText( 'Label' ) ).not.toBeInTheDocument();
352
340
 
353
341
  // Move focus to the button
354
- await user.tab();
342
+ await press.Tab();
355
343
 
356
344
  expect( screen.getByText( 'Label' ) ).toBeVisible();
357
345
 
358
- await cleanupTooltip( user );
346
+ await cleanupTooltip();
359
347
  } );
360
348
 
361
349
  it( 'should populate tooltip with description content for buttons with visible labels (buttons with children)', async () => {
362
- const user = userEvent.setup();
363
-
364
350
  render(
365
351
  <Button
366
352
  label="Label"
@@ -378,7 +364,7 @@ describe( 'Button', () => {
378
364
  } )
379
365
  ).toBeVisible();
380
366
 
381
- await user.tab();
367
+ await press.Tab();
382
368
 
383
369
  expect(
384
370
  screen.getByRole( 'tooltip', {
@@ -386,12 +372,10 @@ describe( 'Button', () => {
386
372
  } )
387
373
  ).toBeVisible();
388
374
 
389
- await cleanupTooltip( user );
375
+ await cleanupTooltip();
390
376
  } );
391
377
 
392
378
  it( 'should allow tooltip disable', async () => {
393
- const user = userEvent.setup();
394
-
395
379
  render(
396
380
  <Button
397
381
  icon={ plusCircle }
@@ -407,14 +391,12 @@ describe( 'Button', () => {
407
391
  expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
408
392
 
409
393
  // Move focus to the button
410
- await user.tab();
394
+ await press.Tab();
411
395
 
412
396
  expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
413
397
  } );
414
398
 
415
399
  it( 'should show the tooltip for empty children', async () => {
416
- const user = userEvent.setup();
417
-
418
400
  render(
419
401
  <Button icon={ plusCircle } label="WordPress" children={ [] } />
420
402
  );
@@ -422,16 +404,14 @@ describe( 'Button', () => {
422
404
  expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
423
405
 
424
406
  // Move focus to the button
425
- await user.tab();
407
+ await press.Tab();
426
408
 
427
409
  expect( screen.getByText( 'WordPress' ) ).toBeVisible();
428
410
 
429
- await cleanupTooltip( user );
411
+ await cleanupTooltip();
430
412
  } );
431
413
 
432
414
  it( 'should not show the tooltip when icon and children defined', async () => {
433
- const user = userEvent.setup();
434
-
435
415
  render(
436
416
  <Button icon={ plusCircle } label="WordPress">
437
417
  Children
@@ -441,14 +421,12 @@ describe( 'Button', () => {
441
421
  expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
442
422
 
443
423
  // Move focus to the button
444
- await user.tab();
424
+ await press.Tab();
445
425
 
446
426
  expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
447
427
  } );
448
428
 
449
429
  it( 'should force showing the tooltip even if icon and children defined', async () => {
450
- const user = userEvent.setup();
451
-
452
430
  render(
453
431
  <Button icon={ plusCircle } label="WordPress" showTooltip>
454
432
  Children
@@ -458,11 +436,11 @@ describe( 'Button', () => {
458
436
  expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
459
437
 
460
438
  // Move focus to the button
461
- await user.tab();
439
+ await press.Tab();
462
440
 
463
441
  expect( screen.getByText( 'WordPress' ) ).toBeVisible();
464
442
 
465
- await cleanupTooltip( user );
443
+ await cleanupTooltip();
466
444
  } );
467
445
 
468
446
  describe( 'using `aria-pressed` prop', () => {
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { render, screen } from '@testing-library/react';
5
- import { press, sleep } from '@ariakit/test';
5
+ import { press } from '@ariakit/test';
6
6
 
7
7
  /**
8
8
  * Internal dependencies
@@ -70,7 +70,6 @@ describe( 'CircularOptionPicker', () => {
70
70
  />
71
71
  );
72
72
 
73
- await sleep();
74
73
  await press.Tab();
75
74
  expect( getOption( 'Option One' ) ).toHaveFocus();
76
75
  await press.ArrowRight();
@@ -90,7 +89,6 @@ describe( 'CircularOptionPicker', () => {
90
89
  />
91
90
  );
92
91
 
93
- await sleep();
94
92
  await press.Tab();
95
93
  expect( getOption( 'Option One' ) ).toHaveFocus();
96
94
  await press.ArrowRight();
@@ -110,7 +108,6 @@ describe( 'CircularOptionPicker', () => {
110
108
  />
111
109
  );
112
110
 
113
- await sleep();
114
111
  await press.Tab();
115
112
  expect( getOption( 'Option One' ) ).toHaveFocus();
116
113
  await press.ArrowRight();
@@ -335,26 +335,28 @@ function UnforwardedColorPalette(
335
335
  ) }
336
336
  />
337
337
  ) }
338
- <CircularOptionPicker
339
- { ...metaProps }
340
- actions={ actions }
341
- options={
342
- hasMultipleColorOrigins ? (
343
- <MultiplePalettes
344
- { ...paletteCommonProps }
345
- headingLevel={ headingLevel }
346
- colors={ colors as PaletteObject[] }
347
- value={ value }
348
- />
349
- ) : (
350
- <SinglePalette
351
- { ...paletteCommonProps }
352
- colors={ colors as ColorObject[] }
353
- value={ value }
354
- />
355
- )
356
- }
357
- />
338
+ { ( colors.length > 0 || actions ) && (
339
+ <CircularOptionPicker
340
+ { ...metaProps }
341
+ actions={ actions }
342
+ options={
343
+ hasMultipleColorOrigins ? (
344
+ <MultiplePalettes
345
+ { ...paletteCommonProps }
346
+ headingLevel={ headingLevel }
347
+ colors={ colors as PaletteObject[] }
348
+ value={ value }
349
+ />
350
+ ) : (
351
+ <SinglePalette
352
+ { ...paletteCommonProps }
353
+ colors={ colors as ColorObject[] }
354
+ value={ value }
355
+ />
356
+ )
357
+ }
358
+ />
359
+ ) }
358
360
  </VStack>
359
361
  );
360
362
  }
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { queryByAttribute, render, screen } from '@testing-library/react';
5
- import { press, sleep, waitFor } from '@ariakit/test';
5
+ import { press, waitFor } from '@ariakit/test';
6
6
 
7
7
  /**
8
8
  * Internal dependencies
@@ -47,7 +47,7 @@ async function renderAndValidate( ...args: Parameters< typeof render > ) {
47
47
  const activeButton = queryByAttribute(
48
48
  'data-active-item',
49
49
  view.baseElement,
50
- ''
50
+ 'true'
51
51
  );
52
52
  expect( activeButton ).not.toBeNull();
53
53
  } );
@@ -178,13 +178,10 @@ describe.each( [
178
178
  );
179
179
  renderAndValidate( <Test /> );
180
180
 
181
- await sleep();
182
181
  await press.Tab();
183
182
  expect( screen.getByText( 'Before' ) ).toHaveFocus();
184
- await sleep();
185
183
  await press.Tab();
186
184
  expect( screen.getByText( 'Item 1' ) ).toHaveFocus();
187
- await sleep();
188
185
  await press.Tab();
189
186
  expect( screen.getByText( 'After' ) ).toHaveFocus();
190
187
  await press.ShiftTab();
@@ -213,7 +210,6 @@ describe.each( [
213
210
 
214
211
  expect( item2 ).toBeDisabled();
215
212
 
216
- await sleep();
217
213
  await press.Tab();
218
214
  expect( item1 ).toHaveFocus();
219
215
  await press.ArrowDown();
@@ -243,7 +239,6 @@ describe.each( [
243
239
  expect( item2 ).toBeEnabled();
244
240
  expect( item2 ).toHaveAttribute( 'aria-disabled', 'true' );
245
241
 
246
- await sleep();
247
242
  await press.Tab();
248
243
  expect( item1 ).toHaveFocus();
249
244
  await press.ArrowDown();
@@ -279,7 +274,6 @@ describe.each( [
279
274
  renderAndValidate( <Test /> );
280
275
  const { item2 } = getOneDimensionalItems();
281
276
 
282
- await sleep();
283
277
  await press.Tab();
284
278
  await waitFor( () => expect( item2 ).toHaveFocus() );
285
279
  } );
@@ -323,7 +317,6 @@ describe.each( [
323
317
  test( 'All directions work with no orientation', async () => {
324
318
  const { item1, item2, item3 } = useOneDimensionalTest();
325
319
 
326
- await sleep();
327
320
  await press.Tab();
328
321
  expect( item1 ).toHaveFocus();
329
322
  await press.ArrowDown();
@@ -361,7 +354,6 @@ describe.each( [
361
354
  orientation: 'horizontal',
362
355
  } );
363
356
 
364
- await sleep();
365
357
  await press.Tab();
366
358
  expect( item1 ).toHaveFocus();
367
359
  await press.ArrowDown();
@@ -391,7 +383,6 @@ describe.each( [
391
383
  orientation: 'vertical',
392
384
  } );
393
385
 
394
- await sleep();
395
386
  await press.Tab();
396
387
  expect( item1 ).toHaveFocus();
397
388
  await press( next );
@@ -421,7 +412,6 @@ describe.each( [
421
412
  loop: true,
422
413
  } );
423
414
 
424
- await sleep();
425
415
  await press.Tab();
426
416
  expect( item1 ).toHaveFocus();
427
417
  await press.ArrowDown();
@@ -444,7 +434,6 @@ describe.each( [
444
434
  const { itemA1, itemA2, itemA3, itemB1, itemB2, itemC1, itemC3 } =
445
435
  useTwoDimensionalTest();
446
436
 
447
- await sleep();
448
437
  await press.Tab();
449
438
  expect( itemA1 ).toHaveFocus();
450
439
  await press.ArrowUp();
@@ -481,7 +470,6 @@ describe.each( [
481
470
  const { itemA1, itemA2, itemA3, itemB1, itemC1, itemC3 } =
482
471
  useTwoDimensionalTest( { loop: true } );
483
472
 
484
- await sleep();
485
473
  await press.Tab();
486
474
  expect( itemA1 ).toHaveFocus();
487
475
  await press( next );
@@ -506,7 +494,6 @@ describe.each( [
506
494
  const { itemA1, itemA2, itemA3, itemB1, itemC1, itemC3 } =
507
495
  useTwoDimensionalTest( { wrap: true } );
508
496
 
509
- await sleep();
510
497
  await press.Tab();
511
498
  expect( itemA1 ).toHaveFocus();
512
499
  await press( next );
@@ -539,7 +526,6 @@ describe.each( [
539
526
  wrap: true,
540
527
  } );
541
528
 
542
- await sleep();
543
529
  await press.Tab();
544
530
  expect( itemA1 ).toHaveFocus();
545
531
  await press( previous );
@@ -555,7 +541,6 @@ describe.each( [
555
541
  test( 'Focus shifts if vertical neighbour unavailable when shift enabled', async () => {
556
542
  const { itemA1, itemB1, itemB2, itemC1 } = useShiftTest( true );
557
543
 
558
- await sleep();
559
544
  await press.Tab();
560
545
  expect( itemA1 ).toHaveFocus();
561
546
  await press.ArrowDown();
@@ -577,7 +562,6 @@ describe.each( [
577
562
  test( 'Focus does not shift if vertical neighbour unavailable when shift not enabled', async () => {
578
563
  const { itemA1, itemB1, itemB2 } = useShiftTest( false );
579
564
 
580
- await sleep();
581
565
  await press.Tab();
582
566
  expect( itemA1 ).toHaveFocus();
583
567
  await press.ArrowDown();