@wordpress/components 21.0.2 → 21.1.2-next.4d3b314fd5.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 (255) hide show
  1. package/CHANGELOG.md +31 -4
  2. package/build/autocomplete/get-default-use-items.js +3 -3
  3. package/build/autocomplete/get-default-use-items.js.map +1 -1
  4. package/build/box-control/unit-control.js +0 -1
  5. package/build/box-control/unit-control.js.map +1 -1
  6. package/build/button/index.js +5 -1
  7. package/build/button/index.js.map +1 -1
  8. package/build/draggable/index.js +3 -6
  9. package/build/draggable/index.js.map +1 -1
  10. package/build/drop-zone/index.js +7 -1
  11. package/build/drop-zone/index.js.map +1 -1
  12. package/build/higher-order/with-filters/index.js +1 -1
  13. package/build/higher-order/with-filters/index.js.map +1 -1
  14. package/build/index.js +6 -0
  15. package/build/index.js.map +1 -1
  16. package/build/menu-item/index.js +4 -3
  17. package/build/menu-item/index.js.map +1 -1
  18. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
  19. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  20. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +15 -6
  21. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  22. package/build/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
  23. package/build/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
  24. package/build/mobile/color-settings/index.native.js +3 -1
  25. package/build/mobile/color-settings/index.native.js.map +1 -1
  26. package/build/mobile/color-settings/picker-screen.native.js +3 -1
  27. package/build/mobile/color-settings/picker-screen.native.js.map +1 -1
  28. package/build/mobile/image/index.native.js +3 -1
  29. package/build/mobile/image/index.native.js.map +1 -1
  30. package/build/mobile/keyboard-avoiding-view/index.ios.js +3 -1
  31. package/build/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
  32. package/build/mobile/link-picker/index.native.js +3 -1
  33. package/build/mobile/link-picker/index.native.js.map +1 -1
  34. package/build/mobile/link-picker/link-picker-results.native.js +6 -4
  35. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  36. package/build/mobile/link-picker/link-picker-screen.native.js +3 -1
  37. package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  38. package/build/mobile/link-settings/index.native.js +24 -6
  39. package/build/mobile/link-settings/index.native.js.map +1 -1
  40. package/build/mobile/link-settings/link-settings-screen.native.js +3 -1
  41. package/build/mobile/link-settings/link-settings-screen.native.js.map +1 -1
  42. package/build/mobile/segmented-control/index.native.js +6 -2
  43. package/build/mobile/segmented-control/index.native.js.map +1 -1
  44. package/build/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
  45. package/build/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
  46. package/build/notice/index.native.js +15 -19
  47. package/build/notice/index.native.js.map +1 -1
  48. package/build/notice/list.native.js +2 -3
  49. package/build/notice/list.native.js.map +1 -1
  50. package/build/palette-edit/index.js +1 -1
  51. package/build/palette-edit/index.js.map +1 -1
  52. package/build/popover/index.js +29 -32
  53. package/build/popover/index.js.map +1 -1
  54. package/build/popover/limit-shift.js +145 -0
  55. package/build/popover/limit-shift.js.map +1 -0
  56. package/build/popover/utils.js +55 -15
  57. package/build/popover/utils.js.map +1 -1
  58. package/build/range-control/input-range.js +1 -15
  59. package/build/range-control/input-range.js.map +1 -1
  60. package/build/range-control/tooltip.js +1 -1
  61. package/build/range-control/tooltip.js.map +1 -1
  62. package/build/range-control/utils.js +2 -58
  63. package/build/range-control/utils.js.map +1 -1
  64. package/build/tools-panel/styles.js +27 -12
  65. package/build/tools-panel/styles.js.map +1 -1
  66. package/build/tools-panel/tools-panel-header/component.js +19 -6
  67. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  68. package/build/tools-panel/tools-panel-header/hook.js +4 -0
  69. package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
  70. package/build/tree-grid/index.js +13 -8
  71. package/build/tree-grid/index.js.map +1 -1
  72. package/build/unit-control/index.js +2 -2
  73. package/build/unit-control/index.js.map +1 -1
  74. package/build/unit-control/index.native.js +10 -2
  75. package/build/unit-control/index.native.js.map +1 -1
  76. package/build/unit-control/styles/unit-control-styles.js +21 -32
  77. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  78. package/build/utils/hooks/use-controlled-state.js +2 -3
  79. package/build/utils/hooks/use-controlled-state.js.map +1 -1
  80. package/build-module/autocomplete/get-default-use-items.js +1 -1
  81. package/build-module/autocomplete/get-default-use-items.js.map +1 -1
  82. package/build-module/box-control/unit-control.js +0 -1
  83. package/build-module/box-control/unit-control.js.map +1 -1
  84. package/build-module/button/index.js +5 -1
  85. package/build-module/button/index.js.map +1 -1
  86. package/build-module/draggable/index.js +2 -5
  87. package/build-module/draggable/index.js.map +1 -1
  88. package/build-module/drop-zone/index.js +7 -1
  89. package/build-module/drop-zone/index.js.map +1 -1
  90. package/build-module/higher-order/with-filters/index.js +2 -2
  91. package/build-module/higher-order/with-filters/index.js.map +1 -1
  92. package/build-module/index.js +1 -1
  93. package/build-module/index.js.map +1 -1
  94. package/build-module/menu-item/index.js +4 -3
  95. package/build-module/menu-item/index.js.map +1 -1
  96. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
  97. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  98. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +13 -4
  99. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  100. package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
  101. package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
  102. package/build-module/mobile/color-settings/index.native.js +3 -1
  103. package/build-module/mobile/color-settings/index.native.js.map +1 -1
  104. package/build-module/mobile/color-settings/picker-screen.native.js +3 -1
  105. package/build-module/mobile/color-settings/picker-screen.native.js.map +1 -1
  106. package/build-module/mobile/image/index.native.js +3 -1
  107. package/build-module/mobile/image/index.native.js.map +1 -1
  108. package/build-module/mobile/keyboard-avoiding-view/index.ios.js +3 -1
  109. package/build-module/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
  110. package/build-module/mobile/link-picker/index.native.js +3 -1
  111. package/build-module/mobile/link-picker/index.native.js.map +1 -1
  112. package/build-module/mobile/link-picker/link-picker-results.native.js +4 -2
  113. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  114. package/build-module/mobile/link-picker/link-picker-screen.native.js +3 -1
  115. package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  116. package/build-module/mobile/link-settings/index.native.js +24 -6
  117. package/build-module/mobile/link-settings/index.native.js.map +1 -1
  118. package/build-module/mobile/link-settings/link-settings-screen.native.js +3 -1
  119. package/build-module/mobile/link-settings/link-settings-screen.native.js.map +1 -1
  120. package/build-module/mobile/segmented-control/index.native.js +6 -2
  121. package/build-module/mobile/segmented-control/index.native.js.map +1 -1
  122. package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
  123. package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
  124. package/build-module/notice/index.native.js +16 -21
  125. package/build-module/notice/index.native.js.map +1 -1
  126. package/build-module/notice/list.native.js +3 -3
  127. package/build-module/notice/list.native.js.map +1 -1
  128. package/build-module/palette-edit/index.js +1 -1
  129. package/build-module/palette-edit/index.js.map +1 -1
  130. package/build-module/popover/index.js +31 -35
  131. package/build-module/popover/index.js.map +1 -1
  132. package/build-module/popover/limit-shift.js +136 -0
  133. package/build-module/popover/limit-shift.js.map +1 -0
  134. package/build-module/popover/utils.js +55 -15
  135. package/build-module/popover/utils.js.map +1 -1
  136. package/build-module/range-control/input-range.js +1 -14
  137. package/build-module/range-control/input-range.js.map +1 -1
  138. package/build-module/range-control/tooltip.js +1 -1
  139. package/build-module/range-control/tooltip.js.map +1 -1
  140. package/build-module/range-control/utils.js +2 -57
  141. package/build-module/range-control/utils.js.map +1 -1
  142. package/build-module/tools-panel/styles.js +23 -12
  143. package/build-module/tools-panel/styles.js.map +1 -1
  144. package/build-module/tools-panel/tools-panel-header/component.js +19 -7
  145. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  146. package/build-module/tools-panel/tools-panel-header/hook.js +4 -0
  147. package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
  148. package/build-module/tree-grid/index.js +13 -8
  149. package/build-module/tree-grid/index.js.map +1 -1
  150. package/build-module/unit-control/index.js +2 -2
  151. package/build-module/unit-control/index.js.map +1 -1
  152. package/build-module/unit-control/index.native.js +10 -2
  153. package/build-module/unit-control/index.native.js.map +1 -1
  154. package/build-module/unit-control/styles/unit-control-styles.js +20 -31
  155. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  156. package/build-module/utils/hooks/use-controlled-state.js +3 -4
  157. package/build-module/utils/hooks/use-controlled-state.js.map +1 -1
  158. package/build-style/style-rtl.css +13 -2
  159. package/build-style/style.css +13 -2
  160. package/build-types/button/index.d.ts.map +1 -1
  161. package/build-types/draggable/index.d.ts.map +1 -1
  162. package/build-types/drop-zone/index.d.ts.map +1 -1
  163. package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
  164. package/build-types/focal-point-picker/styles/focal-point-style.d.ts +3 -3
  165. package/build-types/menu-item/index.d.ts.map +1 -1
  166. package/build-types/popover/index.d.ts.map +1 -1
  167. package/build-types/popover/limit-shift.d.ts +87 -0
  168. package/build-types/popover/limit-shift.d.ts.map +1 -0
  169. package/build-types/popover/stories/e2e/index.d.ts +8 -0
  170. package/build-types/popover/stories/e2e/index.d.ts.map +1 -0
  171. package/build-types/popover/test/index.d.ts +2 -0
  172. package/build-types/popover/test/index.d.ts.map +1 -0
  173. package/build-types/popover/types.d.ts +1 -1
  174. package/build-types/popover/types.d.ts.map +1 -1
  175. package/build-types/popover/utils.d.ts.map +1 -1
  176. package/build-types/range-control/input-range.d.ts.map +1 -1
  177. package/build-types/range-control/stories/index.d.ts.map +1 -1
  178. package/build-types/range-control/types.d.ts +0 -34
  179. package/build-types/range-control/types.d.ts.map +1 -1
  180. package/build-types/range-control/utils.d.ts +1 -12
  181. package/build-types/range-control/utils.d.ts.map +1 -1
  182. package/build-types/spinner/index.d.ts +1 -1
  183. package/build-types/tools-panel/styles.d.ts +6 -0
  184. package/build-types/tools-panel/styles.d.ts.map +1 -1
  185. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  186. package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -0
  187. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  188. package/build-types/tools-panel/types.d.ts +1 -0
  189. package/build-types/tools-panel/types.d.ts.map +1 -1
  190. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -4
  191. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  192. package/build-types/utils/hooks/use-controlled-state.d.ts.map +1 -1
  193. package/package.json +17 -17
  194. package/src/autocomplete/get-default-use-items.js +1 -1
  195. package/src/box-control/unit-control.js +0 -1
  196. package/src/button/index.js +7 -1
  197. package/src/button/test/index.js +36 -0
  198. package/src/color-palette/test/__snapshots__/index.js.snap +169 -1106
  199. package/src/color-palette/test/index.js +107 -61
  200. package/src/draggable/index.js +2 -5
  201. package/src/drop-zone/index.tsx +4 -1
  202. package/src/font-size-picker/stories/e2e/index.js +47 -0
  203. package/src/higher-order/with-filters/index.js +2 -2
  204. package/src/index.js +1 -1
  205. package/src/menu-item/README.md +7 -0
  206. package/src/menu-item/index.js +11 -5
  207. package/src/menu-item/style.scss +1 -0
  208. package/src/menu-item/test/index.js +36 -0
  209. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +9 -0
  210. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +12 -2
  211. package/src/mobile/bottom-sheet/sub-sheet/index.native.js +3 -0
  212. package/src/mobile/color-settings/index.native.js +3 -0
  213. package/src/mobile/color-settings/picker-screen.native.js +3 -0
  214. package/src/mobile/image/index.native.js +3 -0
  215. package/src/mobile/keyboard-avoiding-view/index.ios.js +3 -0
  216. package/src/mobile/link-picker/index.native.js +3 -0
  217. package/src/mobile/link-picker/link-picker-results.native.js +4 -1
  218. package/src/mobile/link-picker/link-picker-screen.native.js +3 -0
  219. package/src/mobile/link-settings/index.native.js +18 -0
  220. package/src/mobile/link-settings/link-settings-screen.native.js +3 -0
  221. package/src/mobile/segmented-control/index.native.js +6 -0
  222. package/src/mobile/utils/use-unit-converter-to-mobile.native.js +6 -0
  223. package/src/notice/index.native.js +17 -20
  224. package/src/notice/list.native.js +7 -3
  225. package/src/palette-edit/index.js +1 -1
  226. package/src/placeholder/style.scss +1 -1
  227. package/src/popover/index.tsx +26 -42
  228. package/src/popover/limit-shift.ts +205 -0
  229. package/src/popover/stories/e2e/index.tsx +25 -0
  230. package/src/popover/test/index.tsx +230 -0
  231. package/src/popover/types.ts +1 -0
  232. package/src/popover/utils.ts +58 -16
  233. package/src/range-control/README.md +6 -7
  234. package/src/range-control/input-range.tsx +1 -21
  235. package/src/range-control/stories/index.tsx +2 -1
  236. package/src/range-control/tooltip.tsx +1 -1
  237. package/src/range-control/types.ts +0 -35
  238. package/src/range-control/utils.ts +3 -75
  239. package/src/tools-panel/stories/index.js +27 -0
  240. package/src/tools-panel/styles.ts +28 -1
  241. package/src/tools-panel/tools-panel-header/component.tsx +12 -5
  242. package/src/tools-panel/tools-panel-header/hook.ts +5 -0
  243. package/src/tools-panel/types.ts +1 -0
  244. package/src/tree-grid/index.js +23 -14
  245. package/src/tree-grid/test/__snapshots__/cell.js.snap +21 -17
  246. package/src/tree-grid/test/__snapshots__/index.js.snap +1 -1
  247. package/src/unit-control/index.native.js +8 -0
  248. package/src/unit-control/index.tsx +2 -2
  249. package/src/unit-control/styles/unit-control-styles.ts +0 -20
  250. package/src/unit-control/test/index.tsx +6 -3
  251. package/src/utils/hooks/use-controlled-state.js +9 -6
  252. package/tsconfig.tsbuildinfo +1 -1
  253. package/src/popover/test/__snapshots__/index.js.snap +0 -34
  254. package/src/popover/test/index.js +0 -164
  255. package/src/unit-control/test/__snapshots__/index.tsx.snap +0 -31
@@ -7,7 +7,7 @@ import type { ForwardedRef } from 'react';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { speak } from '@wordpress/a11y';
10
- import { check, reset, moreVertical, plus } from '@wordpress/icons';
10
+ import { check, moreVertical, plus } from '@wordpress/icons';
11
11
  import { __, _x, sprintf } from '@wordpress/i18n';
12
12
 
13
13
  /**
@@ -20,12 +20,14 @@ import { HStack } from '../../h-stack';
20
20
  import { Heading } from '../../heading';
21
21
  import { useToolsPanelHeader } from './hook';
22
22
  import { contextConnect, WordPressComponentProps } from '../../ui/context';
23
+ import { ResetLabel } from '../styles';
23
24
  import type {
24
25
  ToolsPanelControlsGroupProps,
25
26
  ToolsPanelHeaderProps,
26
27
  } from '../types';
27
28
 
28
29
  const DefaultControlsGroup = ( {
30
+ itemClassName,
29
31
  items,
30
32
  toggleItem,
31
33
  }: ToolsPanelControlsGroupProps ) => {
@@ -33,15 +35,17 @@ const DefaultControlsGroup = ( {
33
35
  return null;
34
36
  }
35
37
 
38
+ const resetSuffix = <ResetLabel aria-hidden>{ __( 'Reset' ) }</ResetLabel>;
39
+
36
40
  return (
37
- <MenuGroup>
41
+ <MenuGroup label={ __( 'Defaults' ) }>
38
42
  { items.map( ( [ label, hasValue ] ) => {
39
43
  if ( hasValue ) {
40
44
  return (
41
45
  <MenuItem
42
46
  key={ label }
47
+ className={ itemClassName }
43
48
  role="menuitem"
44
- icon={ reset }
45
49
  label={ sprintf(
46
50
  // translators: %s: The name of the control being reset e.g. "Padding".
47
51
  __( 'Reset %s' ),
@@ -58,6 +62,7 @@ const DefaultControlsGroup = ( {
58
62
  'assertive'
59
63
  );
60
64
  } }
65
+ suffix={ resetSuffix }
61
66
  >
62
67
  { label }
63
68
  </MenuItem>
@@ -67,8 +72,8 @@ const DefaultControlsGroup = ( {
67
72
  return (
68
73
  <MenuItem
69
74
  key={ label }
75
+ className={ itemClassName }
70
76
  role="menuitemcheckbox"
71
- icon={ check }
72
77
  isSelected
73
78
  aria-disabled
74
79
  >
@@ -89,7 +94,7 @@ const OptionalControlsGroup = ( {
89
94
  }
90
95
 
91
96
  return (
92
- <MenuGroup>
97
+ <MenuGroup label={ __( 'Tools' ) }>
93
98
  { items.map( ( [ label, isSelected ] ) => {
94
99
  const itemLabel = isSelected
95
100
  ? sprintf(
@@ -147,6 +152,7 @@ const ToolsPanelHeader = (
147
152
  ) => {
148
153
  const {
149
154
  areAllOptionalControlsHidden,
155
+ defaultControlsItemClassName,
150
156
  dropdownMenuClassName,
151
157
  hasMenuItems,
152
158
  headingClassName,
@@ -197,6 +203,7 @@ const ToolsPanelHeader = (
197
203
  <DefaultControlsGroup
198
204
  items={ defaultItems }
199
205
  toggleItem={ toggleItem }
206
+ itemClassName={ defaultControlsItemClassName }
200
207
  />
201
208
  <OptionalControlsGroup
202
209
  items={ optionalItems }
@@ -33,12 +33,17 @@ export function useToolsPanelHeader(
33
33
  return cx( styles.ToolsPanelHeading );
34
34
  }, [ cx ] );
35
35
 
36
+ const defaultControlsItemClassName = useMemo( () => {
37
+ return cx( styles.DefaultControlsItem );
38
+ }, [ cx ] );
39
+
36
40
  const { menuItems, hasMenuItems, areAllOptionalControlsHidden } =
37
41
  useToolsPanelContext();
38
42
 
39
43
  return {
40
44
  ...otherProps,
41
45
  areAllOptionalControlsHidden,
46
+ defaultControlsItemClassName,
42
47
  dropdownMenuClassName,
43
48
  hasMenuItems,
44
49
  headingClassName,
@@ -147,6 +147,7 @@ export type ToolsPanelContext = {
147
147
  };
148
148
 
149
149
  export type ToolsPanelControlsGroupProps = {
150
+ itemClassName?: string;
150
151
  items: [ string, boolean ][];
151
152
  toggleItem: ( label: string ) => void;
152
153
  };
@@ -36,12 +36,13 @@ function getRowFocusables( rowElement ) {
36
36
  * Renders both a table and tbody element, used to create a tree hierarchy.
37
37
  *
38
38
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/components/src/tree-grid/README.md
39
- * @param {Object} props Component props.
40
- * @param {WPElement} props.children Children to be rendered.
41
- * @param {Function} props.onExpandRow Callback to fire when row is expanded.
42
- * @param {Function} props.onCollapseRow Callback to fire when row is collapsed.
43
- * @param {Function} props.onFocusRow Callback to fire when moving focus to a different row.
44
- * @param {Object} ref A ref to the underlying DOM table element.
39
+ * @param {Object} props Component props.
40
+ * @param {WPElement} props.children Children to be rendered.
41
+ * @param {Function} props.onExpandRow Callback to fire when row is expanded.
42
+ * @param {Function} props.onCollapseRow Callback to fire when row is collapsed.
43
+ * @param {Function} props.onFocusRow Callback to fire when moving focus to a different row.
44
+ * @param {string} props.applicationAriaLabel Label to use for the application role.
45
+ * @param {Object} ref A ref to the underlying DOM table element.
45
46
  */
46
47
  function TreeGrid(
47
48
  {
@@ -49,6 +50,7 @@ function TreeGrid(
49
50
  onExpandRow = () => {},
50
51
  onCollapseRow = () => {},
51
52
  onFocusRow = () => {},
53
+ applicationAriaLabel,
52
54
  ...props
53
55
  },
54
56
  ref
@@ -286,14 +288,21 @@ function TreeGrid(
286
288
  /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */
287
289
  return (
288
290
  <RovingTabIndexContainer>
289
- <table
290
- { ...props }
291
- role="treegrid"
292
- onKeyDown={ onKeyDown }
293
- ref={ ref }
294
- >
295
- <tbody>{ children }</tbody>
296
- </table>
291
+ {
292
+ // Prevent browser mode from triggering in NVDA by wrapping List View
293
+ // in a role=application wrapper.
294
+ // see: https://github.com/WordPress/gutenberg/issues/43729
295
+ }
296
+ <div role="application" aria-label={ applicationAriaLabel }>
297
+ <table
298
+ { ...props }
299
+ role="treegrid"
300
+ onKeyDown={ onKeyDown }
301
+ ref={ ref }
302
+ >
303
+ <tbody>{ children }</tbody>
304
+ </table>
305
+ </div>
297
306
  </RovingTabIndexContainer>
298
307
  );
299
308
  /* eslint-enable jsx-a11y/no-noninteractive-element-to-interactive-role */
@@ -1,23 +1,27 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`TreeGridCell uses a child render function to render children 1`] = `
4
- <table
5
- onKeyDown={[Function]}
6
- role="treegrid"
4
+ <div
5
+ role="application"
7
6
  >
8
- <tbody>
9
- <tr>
10
- <td
11
- role="gridcell"
12
- >
13
- <button
14
- className="my-button"
15
- onFocus={[Function]}
7
+ <table
8
+ onKeyDown={[Function]}
9
+ role="treegrid"
10
+ >
11
+ <tbody>
12
+ <tr>
13
+ <td
14
+ role="gridcell"
16
15
  >
17
- Click Me!
18
- </button>
19
- </td>
20
- </tr>
21
- </tbody>
22
- </table>
16
+ <button
17
+ className="my-button"
18
+ onFocus={[Function]}
19
+ >
20
+ Click Me!
21
+ </button>
22
+ </td>
23
+ </tr>
24
+ </tbody>
25
+ </table>
26
+ </div>
23
27
  `;
@@ -1,3 +1,3 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`TreeGrid simple rendering renders a table, tbody and any child elements 1`] = `"<table role=\\"treegrid\\"><tbody><tr role=\\"row\\" aria-level=\\"1\\" aria-posinset=\\"1\\" aria-setsize=\\"1\\"><td role=\\"gridcell\\">Test</td></tr></tbody></table>"`;
3
+ exports[`TreeGrid simple rendering renders a table, tbody and any child elements 1`] = `"<div role=\\"application\\"><table role=\\"treegrid\\"><tbody><tr role=\\"row\\" aria-level=\\"1\\" aria-posinset=\\"1\\" aria-setsize=\\"1\\"><td role=\\"gridcell\\">Test</td></tr></tbody></table></div>"`;
@@ -47,6 +47,10 @@ function UnitControl( {
47
47
  if ( pickerRef?.current ) {
48
48
  pickerRef.current.presentPicker();
49
49
  }
50
+ // Disable reason: this should be fixed by the native team.
51
+ // It would be great if this could be done in the context of
52
+ // https://github.com/WordPress/gutenberg/pull/39218
53
+ // eslint-disable-next-line react-hooks/exhaustive-deps
50
54
  }, [ pickerRef?.current ] );
51
55
 
52
56
  const currentInputValue = currentInput === null ? value : currentInput;
@@ -102,6 +106,10 @@ function UnitControl( {
102
106
  anchorNodeRef?.current
103
107
  ? findNodeHandle( anchorNodeRef?.current )
104
108
  : undefined,
109
+ // Disable reason: this should be fixed by the native team.
110
+ // It would be great if this could be done in the context of
111
+ // https://github.com/WordPress/gutenberg/pull/39218
112
+ // eslint-disable-next-line react-hooks/exhaustive-deps
105
113
  [ anchorNodeRef?.current ]
106
114
  );
107
115
 
@@ -100,7 +100,7 @@ function UnforwardedUnitControl(
100
100
  if ( parsedUnit !== undefined ) {
101
101
  setUnit( parsedUnit );
102
102
  }
103
- }, [ parsedUnit ] );
103
+ }, [ parsedUnit, setUnit ] );
104
104
 
105
105
  // Stores parsed value for hand-off in state reducer.
106
106
  const refParsedQuantity = useRef< number | undefined >( undefined );
@@ -265,7 +265,7 @@ function UnforwardedUnitControl(
265
265
  autoComplete={ autoComplete }
266
266
  className={ classes }
267
267
  disabled={ disabled }
268
- disableUnits={ disableUnits }
268
+ hideHTMLArrows
269
269
  isPressEnterToChange={ isPressEnterToChange }
270
270
  label={ label }
271
271
  onBlur={ handleOnBlur }
@@ -18,10 +18,6 @@ type SelectProps = {
18
18
  selectSize: SelectSize;
19
19
  };
20
20
 
21
- type InputProps = {
22
- disableUnits?: boolean;
23
- };
24
-
25
21
  export const Root = styled.div`
26
22
  box-sizing: border-box;
27
23
  position: relative;
@@ -32,30 +28,14 @@ export const Root = styled.div`
32
28
  }
33
29
  `;
34
30
 
35
- const arrowStyles = ( { disableUnits }: InputProps ) => {
36
- if ( disableUnits ) return '';
37
-
38
- return css`
39
- &::-webkit-outer-spin-button,
40
- &::-webkit-inner-spin-button {
41
- -webkit-appearance: none;
42
- margin: 0;
43
- }
44
- `;
45
- };
46
-
47
31
  // TODO: Resolve need to use &&& to increase specificity
48
32
  // https://github.com/WordPress/gutenberg/issues/18483
49
33
 
50
34
  export const ValueInput = styled( NumberControl )`
51
35
  &&& {
52
36
  input {
53
- appearance: none;
54
- -moz-appearance: textfield;
55
37
  display: block;
56
38
  width: 100%;
57
-
58
- ${ arrowStyles };
59
39
  }
60
40
  }
61
41
  `;
@@ -111,9 +111,12 @@ describe( 'UnitControl', () => {
111
111
  <UnitControl className="hello" />
112
112
  );
113
113
 
114
- expect( withoutClassName.firstChild ).toMatchDiffSnapshot(
115
- withClassName.firstChild
116
- );
114
+ expect(
115
+ withoutClassName.querySelector( '.components-unit-control' )
116
+ ).not.toHaveClass( 'hello' );
117
+ expect(
118
+ withClassName.querySelector( '.components-unit-control' )
119
+ ).toHaveClass( 'hello' );
117
120
  } );
118
121
 
119
122
  it( 'should not render select, if units are disabled', () => {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useEffect, useState } from '@wordpress/element';
4
+ import { useEffect, useState, useCallback } from '@wordpress/element';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -70,11 +70,14 @@ function useControlledState( currentState, options = defaultOptions ) {
70
70
 
71
71
  /* eslint-disable jsdoc/no-undefined-types */
72
72
  /** @type {(nextState: T) => void} */
73
- const setState = ( nextState ) => {
74
- if ( ! hasCurrentState ) {
75
- setInternalState( nextState );
76
- }
77
- };
73
+ const setState = useCallback(
74
+ ( nextState ) => {
75
+ if ( ! hasCurrentState ) {
76
+ setInternalState( nextState );
77
+ }
78
+ },
79
+ [ hasCurrentState ]
80
+ );
78
81
  /* eslint-enable jsdoc/no-undefined-types */
79
82
 
80
83
  return [ state, setState ];