@wordpress/block-editor 8.3.1 → 8.4.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 (174) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -0
  3. package/build/components/block-list/block-html.js +4 -1
  4. package/build/components/block-list/block-html.js.map +1 -1
  5. package/build/components/block-list/block.js +4 -1
  6. package/build/components/block-list/block.js.map +1 -1
  7. package/build/components/block-list/use-block-props/use-focus-first-element.js +19 -0
  8. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  9. package/build/components/block-lock/index.js +32 -0
  10. package/build/components/block-lock/index.js.map +1 -0
  11. package/build/components/block-lock/menu-item.js +58 -0
  12. package/build/components/block-lock/menu-item.js.map +1 -0
  13. package/build/components/block-lock/modal.js +143 -0
  14. package/build/components/block-lock/modal.js.map +1 -0
  15. package/build/components/block-lock/toolbar.js +70 -0
  16. package/build/components/block-lock/toolbar.js.map +1 -0
  17. package/build/components/block-settings-menu/block-settings-dropdown.js +26 -6
  18. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  19. package/build/components/block-settings-menu-controls/index.js +19 -9
  20. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  21. package/build/components/block-title/use-block-display-title.js +7 -5
  22. package/build/components/block-title/use-block-display-title.js.map +1 -1
  23. package/build/components/block-toolbar/index.js +4 -0
  24. package/build/components/block-toolbar/index.js.map +1 -1
  25. package/build/components/border-radius-control/index.js +0 -1
  26. package/build/components/border-radius-control/index.js.map +1 -1
  27. package/build/components/border-radius-control/utils.js +1 -1
  28. package/build/components/border-radius-control/utils.js.map +1 -1
  29. package/build/components/colors-gradients/control.js +3 -1
  30. package/build/components/colors-gradients/control.js.map +1 -1
  31. package/build/components/date-format-picker/index.js +132 -0
  32. package/build/components/date-format-picker/index.js.map +1 -0
  33. package/build/components/index.js +9 -0
  34. package/build/components/index.js.map +1 -1
  35. package/build/components/line-height-control/index.js +5 -3
  36. package/build/components/line-height-control/index.js.map +1 -1
  37. package/build/components/list-view/block-select-button.js +4 -22
  38. package/build/components/list-view/block-select-button.js.map +1 -1
  39. package/build/components/list-view/block.js +33 -12
  40. package/build/components/list-view/block.js.map +1 -1
  41. package/build/components/list-view/branch.js +16 -13
  42. package/build/components/list-view/branch.js.map +1 -1
  43. package/build/components/list-view/index.js +7 -1
  44. package/build/components/list-view/index.js.map +1 -1
  45. package/build/components/list-view/use-block-selection.js +9 -2
  46. package/build/components/list-view/use-block-selection.js.map +1 -1
  47. package/build/components/rich-text/index.js +2 -2
  48. package/build/components/rich-text/index.js.map +1 -1
  49. package/build/components/rich-text/index.native.js +13 -9
  50. package/build/components/rich-text/index.native.js.map +1 -1
  51. package/build/components/url-popover/image-url-input-ui.js +11 -27
  52. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  53. package/build/hooks/anchor.js +7 -6
  54. package/build/hooks/anchor.js.map +1 -1
  55. package/build/hooks/gap.js +70 -5
  56. package/build/hooks/gap.js.map +1 -1
  57. package/build/layouts/flex.js +8 -5
  58. package/build/layouts/flex.js.map +1 -1
  59. package/build/layouts/flow.js +16 -12
  60. package/build/layouts/flow.js.map +1 -1
  61. package/build/store/defaults.js +1 -0
  62. package/build/store/defaults.js.map +1 -1
  63. package/build/store/selectors.js +29 -3
  64. package/build/store/selectors.js.map +1 -1
  65. package/build-module/components/block-list/block-html.js +5 -2
  66. package/build-module/components/block-list/block-html.js.map +1 -1
  67. package/build-module/components/block-list/block.js +5 -2
  68. package/build-module/components/block-list/block.js.map +1 -1
  69. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +18 -0
  70. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  71. package/build-module/components/block-lock/index.js +4 -0
  72. package/build-module/components/block-lock/index.js.map +1 -0
  73. package/build-module/components/block-lock/menu-item.js +44 -0
  74. package/build-module/components/block-lock/menu-item.js.map +1 -0
  75. package/build-module/components/block-lock/modal.js +128 -0
  76. package/build-module/components/block-lock/modal.js.map +1 -0
  77. package/build-module/components/block-lock/toolbar.js +55 -0
  78. package/build-module/components/block-lock/toolbar.js.map +1 -0
  79. package/build-module/components/block-settings-menu/block-settings-dropdown.js +26 -6
  80. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  81. package/build-module/components/block-settings-menu-controls/index.js +18 -9
  82. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  83. package/build-module/components/block-title/use-block-display-title.js +7 -5
  84. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  85. package/build-module/components/block-toolbar/index.js +3 -0
  86. package/build-module/components/block-toolbar/index.js.map +1 -1
  87. package/build-module/components/border-radius-control/index.js +0 -1
  88. package/build-module/components/border-radius-control/index.js.map +1 -1
  89. package/build-module/components/border-radius-control/utils.js +1 -1
  90. package/build-module/components/border-radius-control/utils.js.map +1 -1
  91. package/build-module/components/colors-gradients/control.js +3 -1
  92. package/build-module/components/colors-gradients/control.js.map +1 -1
  93. package/build-module/components/date-format-picker/index.js +122 -0
  94. package/build-module/components/date-format-picker/index.js.map +1 -0
  95. package/build-module/components/index.js +1 -0
  96. package/build-module/components/index.js.map +1 -1
  97. package/build-module/components/line-height-control/index.js +5 -3
  98. package/build-module/components/line-height-control/index.js.map +1 -1
  99. package/build-module/components/list-view/block-select-button.js +5 -20
  100. package/build-module/components/list-view/block-select-button.js.map +1 -1
  101. package/build-module/components/list-view/block.js +31 -12
  102. package/build-module/components/list-view/block.js.map +1 -1
  103. package/build-module/components/list-view/branch.js +16 -13
  104. package/build-module/components/list-view/branch.js.map +1 -1
  105. package/build-module/components/list-view/index.js +7 -1
  106. package/build-module/components/list-view/index.js.map +1 -1
  107. package/build-module/components/list-view/use-block-selection.js +10 -3
  108. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  109. package/build-module/components/rich-text/index.js +2 -2
  110. package/build-module/components/rich-text/index.js.map +1 -1
  111. package/build-module/components/rich-text/index.native.js +13 -9
  112. package/build-module/components/rich-text/index.native.js.map +1 -1
  113. package/build-module/components/url-popover/image-url-input-ui.js +12 -28
  114. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  115. package/build-module/hooks/anchor.js +7 -6
  116. package/build-module/hooks/anchor.js.map +1 -1
  117. package/build-module/hooks/gap.js +68 -7
  118. package/build-module/hooks/gap.js.map +1 -1
  119. package/build-module/layouts/flex.js +7 -5
  120. package/build-module/layouts/flex.js.map +1 -1
  121. package/build-module/layouts/flow.js +15 -12
  122. package/build-module/layouts/flow.js.map +1 -1
  123. package/build-module/store/defaults.js +1 -0
  124. package/build-module/store/defaults.js.map +1 -1
  125. package/build-module/store/selectors.js +24 -1
  126. package/build-module/store/selectors.js.map +1 -1
  127. package/build-style/style-rtl.css +157 -0
  128. package/build-style/style.css +157 -0
  129. package/package.json +28 -27
  130. package/src/components/block-list/block-html.js +8 -4
  131. package/src/components/block-list/block.js +5 -1
  132. package/src/components/block-list/use-block-props/use-focus-first-element.js +28 -0
  133. package/src/components/block-lock/index.js +3 -0
  134. package/src/components/block-lock/menu-item.js +52 -0
  135. package/src/components/block-lock/modal.js +165 -0
  136. package/src/components/block-lock/style.scss +67 -0
  137. package/src/components/block-lock/toolbar.js +58 -0
  138. package/src/components/block-settings-menu/block-settings-dropdown.js +47 -5
  139. package/src/components/block-settings-menu-controls/index.js +33 -12
  140. package/src/components/block-title/README.md +6 -1
  141. package/src/components/block-title/test/index.js +43 -1
  142. package/src/components/block-title/use-block-display-title.js +9 -6
  143. package/src/components/block-toolbar/index.js +6 -0
  144. package/src/components/block-toolbar/style.scss +4 -0
  145. package/src/components/block-tools/style.scss +29 -0
  146. package/src/components/border-radius-control/index.js +0 -1
  147. package/src/components/border-radius-control/test/utils.js +4 -0
  148. package/src/components/border-radius-control/utils.js +2 -1
  149. package/src/components/color-palette/test/__snapshots__/control.js.snap +70 -4
  150. package/src/components/colors-gradients/control.js +1 -1
  151. package/src/components/colors-gradients/style.scss +6 -0
  152. package/src/components/date-format-picker/README.md +58 -0
  153. package/src/components/date-format-picker/index.js +161 -0
  154. package/src/components/date-format-picker/style.scss +31 -0
  155. package/src/components/index.js +1 -0
  156. package/src/components/line-height-control/index.js +3 -3
  157. package/src/components/link-control/README.md +1 -1
  158. package/src/components/list-view/block-select-button.js +2 -29
  159. package/src/components/list-view/block.js +47 -12
  160. package/src/components/list-view/branch.js +37 -15
  161. package/src/components/list-view/index.js +6 -0
  162. package/src/components/list-view/use-block-selection.js +15 -2
  163. package/src/components/rich-text/index.js +1 -1
  164. package/src/components/rich-text/index.native.js +24 -8
  165. package/src/components/url-popover/image-url-input-ui.js +16 -29
  166. package/src/hooks/anchor.js +8 -6
  167. package/src/hooks/gap.js +83 -12
  168. package/src/hooks/test/gap.js +42 -0
  169. package/src/layouts/flex.js +6 -3
  170. package/src/layouts/flow.js +16 -11
  171. package/src/store/defaults.js +1 -0
  172. package/src/store/selectors.js +26 -1
  173. package/src/store/test/selectors.js +63 -0
  174. package/src/style.scss +2 -0
@@ -69,13 +69,64 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
69
69
  min-height: 0;
70
70
  }
71
71
 
72
+ .emotion-10 {
73
+ display: -webkit-box;
74
+ display: -webkit-flex;
75
+ display: -ms-flexbox;
76
+ display: flex;
77
+ -webkit-align-items: flex-start;
78
+ -webkit-box-align: flex-start;
79
+ -ms-flex-align: flex-start;
80
+ align-items: flex-start;
81
+ -webkit-flex-direction: row;
82
+ -ms-flex-direction: row;
83
+ flex-direction: row;
84
+ -webkit-box-pack: justify;
85
+ -webkit-justify-content: space-between;
86
+ justify-content: space-between;
87
+ width: 100%;
88
+ }
89
+
90
+ .emotion-10>*+*:not( marquee ) {
91
+ margin-left: calc(4px * 2);
92
+ }
93
+
94
+ .emotion-10>* {
95
+ min-width: 0;
96
+ }
97
+
98
+ .emotion-13 {
99
+ display: block;
100
+ overflow: hidden;
101
+ text-overflow: ellipsis;
102
+ white-space: nowrap;
103
+ display: block;
104
+ max-height: 100%;
105
+ max-width: 100%;
106
+ min-height: 0;
107
+ min-width: 0;
108
+ -webkit-flex: 1;
109
+ -ms-flex: 1;
110
+ flex: 1;
111
+ }
112
+
113
+ .emotion-15 {
114
+ display: block;
115
+ max-height: 100%;
116
+ max-width: 100%;
117
+ min-height: 0;
118
+ min-width: 0;
119
+ }
120
+
72
121
  <div
73
122
  className="components-base-control block-editor-color-gradient-control emotion-0 emotion-1"
74
123
  >
75
124
  <div
76
125
  className="components-base-control__field emotion-2 emotion-3"
77
126
  >
78
- <fieldset>
127
+ <fieldset
128
+ className="block-editor-color-gradient-control__fieldset"
129
+ >
79
130
  <div
80
131
  className="components-flex components-h-stack components-v-stack emotion-4 emotion-5"
81
132
  data-wp-c16t={true}
@@ -104,8 +155,10 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
104
155
  <button
105
156
  aria-expanded={false}
106
157
  aria-haspopup="true"
107
- aria-label="Custom color picker"
108
- className="components-color-palette__custom-color"
158
+ aria-label="Custom color picker. The currently selected color is called \\"red\\" and has a value of \\"f00\\"."
159
+ className="components-flex components-color-palette__custom-color emotion-10 emotion-5"
160
+ data-wp-c16t={true}
161
+ data-wp-component="Flex"
109
162
  onClick={[Function]}
110
163
  style={
111
164
  Object {
@@ -114,7 +167,20 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
114
167
  }
115
168
  }
116
169
  >
117
- #f00
170
+ <span
171
+ className="components-truncate components-flex-item components-color-palette__custom-color-name emotion-5 emotion-13 emotion-5"
172
+ data-wp-c16t={true}
173
+ data-wp-component="FlexItem"
174
+ >
175
+ red
176
+ </span>
177
+ <span
178
+ className="components-flex-item components-color-palette__custom-color-value emotion-15 emotion-5"
179
+ data-wp-c16t={true}
180
+ data-wp-component="FlexItem"
181
+ >
182
+ f00
183
+ </span>
118
184
  </button>
119
185
  </div>
120
186
  <div
@@ -66,7 +66,7 @@ function ColorGradientControlInner( {
66
66
  className
67
67
  ) }
68
68
  >
69
- <fieldset>
69
+ <fieldset className="block-editor-color-gradient-control__fieldset">
70
70
  <VStack spacing={ 1 }>
71
71
  { showTitle && (
72
72
  <legend>
@@ -4,6 +4,12 @@
4
4
  }
5
5
  }
6
6
 
7
+ .block-editor-color-gradient-control__fieldset {
8
+ // Prevents the `fieldset` from growing beyond its parent's size
9
+ // in order to fit its content.
10
+ min-width: 0;
11
+ }
12
+
7
13
  .block-editor-panel-color-gradient-settings {
8
14
  .block-editor-panel-color-gradient-settings__panel-title {
9
15
  display: flex;
@@ -0,0 +1,58 @@
1
+ # DateFormatPicker
2
+
3
+ The `DateFormatPicker` component renders controls that let the user choose a
4
+ _date format_. That is, how they want their dates to be formatted.
5
+
6
+ A user can pick _Default_ to use the default date format (usually set at the
7
+ site level).
8
+
9
+ Otherwise, a user may choose a suggested date format or type in their own date
10
+ format by selecting _Custom_.
11
+
12
+ All date format strings should be in the format accepted by by the [`dateI18n`
13
+ function in
14
+ `@wordpress/date`](https://github.com/WordPress/gutenberg/tree/trunk/packages/date#datei18n).
15
+
16
+ ## Usage
17
+
18
+ ```jsx
19
+ import { DateFormatPicker } from '@wordpress/block-editor';
20
+
21
+ const Example = () => {
22
+ const [ format, setFormat ] = useState( null );
23
+ return (
24
+ <DateFormatPicker
25
+ format={ format }
26
+ defaultFormat={ 'M j, Y' }
27
+ onChange={ ( nextFormat ) =>
28
+ setFormat( nextFormat );
29
+ }
30
+ />
31
+ );
32
+ };
33
+ ```
34
+
35
+ ## Props
36
+
37
+ ### `format`
38
+
39
+ The current date format selected by the user. If `null`, _Default_ is selected.
40
+
41
+ - Type: `string|null`
42
+ - Required: Yes
43
+
44
+ ### `defaultFormat`
45
+
46
+ The default format string. Used to show to the user what the date will look like
47
+ if _Default_ is selected.
48
+
49
+ - Type: `string`
50
+ - Required: Yes
51
+
52
+ ### `onChange`
53
+
54
+ Called when the user makes a selection, or when the user types in a date format.
55
+ `null` indicates that _Default_ is selected.
56
+
57
+ - Type: `( format: string|null ) => void`
58
+ - Required: Yes
@@ -0,0 +1,161 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { uniq } from 'lodash';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { _x, __ } from '@wordpress/i18n';
10
+ import { dateI18n } from '@wordpress/date';
11
+ import { useState, createInterpolateElement } from '@wordpress/element';
12
+ import {
13
+ TextControl,
14
+ ExternalLink,
15
+ VisuallyHidden,
16
+ CustomSelectControl,
17
+ BaseControl,
18
+ ToggleControl,
19
+ } from '@wordpress/components';
20
+
21
+ // So that we can illustrate the different formats in the dropdown properly,
22
+ // show a date that has a day greater than 12 and a month with more than three
23
+ // letters. Here we're using 2022-01-25 which is when WordPress 5.9 was
24
+ // released.
25
+ const EXAMPLE_DATE = new Date( 2022, 0, 25 );
26
+
27
+ /**
28
+ * The `DateFormatPicker` component renders controls that let the user choose a
29
+ * _date format_. That is, how they want their dates to be formatted.
30
+ *
31
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/date-format-picker/README.md
32
+ *
33
+ * @param {Object} props
34
+ * @param {string|null} props.format The selected date
35
+ * format. If
36
+ * `null`,
37
+ * _Default_ is
38
+ * selected.
39
+ * @param {string} props.defaultFormat The date format that
40
+ * will be used if the
41
+ * user selects
42
+ * 'Default'.
43
+ * @param {( format: string|null ) => void} props.onChange Called when a
44
+ * selection is
45
+ * made. If `null`,
46
+ * _Default_ is
47
+ * selected.
48
+ */
49
+ export default function DateFormatPicker( {
50
+ format,
51
+ defaultFormat,
52
+ onChange,
53
+ } ) {
54
+ return (
55
+ <fieldset className="block-editor-date-format-picker">
56
+ <VisuallyHidden as="legend">{ __( 'Date format' ) }</VisuallyHidden>
57
+ <ToggleControl
58
+ label={
59
+ <>
60
+ { __( 'Default format' ) }
61
+ <span className="block-editor-date-format-picker__default-format-toggle-control__hint">
62
+ { dateI18n( defaultFormat, EXAMPLE_DATE ) }
63
+ </span>
64
+ </>
65
+ }
66
+ checked={ ! format }
67
+ onChange={ ( checked ) =>
68
+ onChange( checked ? null : defaultFormat )
69
+ }
70
+ />
71
+ { format && (
72
+ <NonDefaultControls format={ format } onChange={ onChange } />
73
+ ) }
74
+ </fieldset>
75
+ );
76
+ }
77
+
78
+ function NonDefaultControls( { format, onChange } ) {
79
+ // Suggest a short format, medium format, long format, and a standardised
80
+ // (YYYY-MM-DD) format. The short, medium, and long formats are localised as
81
+ // different languages have different ways of writing these. For example, 'F
82
+ // j, Y' (April 20, 2022) in American English (en_US) is 'j. F Y' (20. April
83
+ // 2022) in German (de). The resultant array is de-duplicated as some
84
+ // languages will use the same format string for short, medium, and long
85
+ // formats.
86
+ const suggestedFormats = uniq( [
87
+ 'Y-m-d',
88
+ _x( 'n/j/Y', 'short date format' ),
89
+ _x( 'n/j/Y g:i A', 'short date format with time' ),
90
+ _x( 'M j, Y', 'medium date format' ),
91
+ _x( 'M j, Y g:i A', 'medium date format with time' ),
92
+ _x( 'F j, Y', 'long date format' ),
93
+ ] );
94
+
95
+ const suggestedOptions = suggestedFormats.map(
96
+ ( suggestedFormat, index ) => ( {
97
+ key: `suggested-${ index }`,
98
+ name: dateI18n( suggestedFormat, EXAMPLE_DATE ),
99
+ format: suggestedFormat,
100
+ } )
101
+ );
102
+ const customOption = {
103
+ key: 'custom',
104
+ name: __( 'Custom' ),
105
+ className:
106
+ 'block-editor-date-format-picker__custom-format-select-control__custom-option',
107
+ __experimentalHint: __( 'Enter your own date format' ),
108
+ };
109
+
110
+ const [ isCustom, setIsCustom ] = useState(
111
+ () => !! format && ! suggestedFormats.includes( format )
112
+ );
113
+
114
+ return (
115
+ <>
116
+ <BaseControl className="block-editor-date-format-picker__custom-format-select-control">
117
+ <CustomSelectControl
118
+ label={ __( 'Choose a format' ) }
119
+ options={ [ ...suggestedOptions, customOption ] }
120
+ value={
121
+ isCustom
122
+ ? customOption
123
+ : suggestedOptions.find(
124
+ ( option ) => option.format === format
125
+ ) ?? customOption
126
+ }
127
+ onChange={ ( { selectedItem } ) => {
128
+ if ( selectedItem === customOption ) {
129
+ setIsCustom( true );
130
+ } else {
131
+ setIsCustom( false );
132
+ onChange( selectedItem.format );
133
+ }
134
+ } }
135
+ />
136
+ </BaseControl>
137
+ { isCustom && (
138
+ <TextControl
139
+ label={ __( 'Custom format' ) }
140
+ hideLabelFromVision
141
+ help={ createInterpolateElement(
142
+ __(
143
+ 'Enter a date or time <Link>format string</Link>.'
144
+ ),
145
+ {
146
+ Link: (
147
+ <ExternalLink
148
+ href={ __(
149
+ 'https://wordpress.org/support/article/formatting-date-and-time/'
150
+ ) }
151
+ />
152
+ ),
153
+ }
154
+ ) }
155
+ value={ format }
156
+ onChange={ ( value ) => onChange( value ) }
157
+ />
158
+ ) }
159
+ </>
160
+ );
161
+ }
@@ -0,0 +1,31 @@
1
+ .block-editor-date-format-picker {
2
+ margin-bottom: $grid-unit-20;
3
+ }
4
+
5
+ .block-editor-date-format-picker__default-format-toggle-control__hint {
6
+ color: $gray-700;
7
+ display: block;
8
+ }
9
+
10
+ .block-editor-date-format-picker__custom-format-select-control {
11
+ &.components-base-control {
12
+ margin-bottom: 0;
13
+ }
14
+
15
+ .components-custom-select-control__button {
16
+ width: 100%;
17
+ }
18
+ }
19
+
20
+ .block-editor-date-format-picker__custom-format-select-control__custom-option {
21
+ border-top: 1px solid $gray-300;
22
+
23
+ &.has-hint {
24
+ grid-template-columns: auto 30px;
25
+ }
26
+
27
+ .components-custom-select-control__item-hint {
28
+ grid-row: 2;
29
+ text-align: left;
30
+ }
31
+ }
@@ -42,6 +42,7 @@ export {
42
42
  export { default as ColorPalette } from './color-palette';
43
43
  export { default as ColorPaletteControl } from './color-palette/control';
44
44
  export { default as ContrastChecker } from './contrast-checker';
45
+ export { default as __experimentalDateFormatPicker } from './date-format-picker';
45
46
  export { default as __experimentalDuotoneControl } from './duotone-control';
46
47
  export { default as __experimentalFontAppearanceControl } from './font-appearance-control';
47
48
  export { default as __experimentalFontFamilyControl } from './font-family';
@@ -37,7 +37,7 @@ export default function LineHeightControl( {
37
37
  * Step up/down actions can be triggered by keydowns of the up/down arrow keys,
38
38
  * or by clicking the spin buttons.
39
39
  */
40
- switch ( nextValue ) {
40
+ switch ( `${ nextValue }` ) {
41
41
  case `${ STEP }`:
42
42
  // Increment by step value.
43
43
  return BASE_DEFAULT_VALUE + STEP;
@@ -63,8 +63,8 @@ export default function LineHeightControl( {
63
63
  const wasTypedOrPasted = [ 'insertText', 'insertFromPaste' ].includes(
64
64
  action.payload.event.nativeEvent?.inputType
65
65
  );
66
- state.value = adjustNextValue( state.value, wasTypedOrPasted );
67
- return state;
66
+ const value = adjustNextValue( state.value, wasTypedOrPasted );
67
+ return { ...state, value };
68
68
  };
69
69
 
70
70
  const value = isDefined ? lineHeight : RESET_VALUE;
@@ -85,7 +85,7 @@ Value change handler, called with the updated value if the user selects a new li
85
85
  <LinkControl
86
86
  onChange={ ( nextValue ) => {
87
87
  console.log( `The selected item URL: ${ nextValue.url }.` );
88
- }
88
+ } }
89
89
  />
90
90
  ```
91
91
 
@@ -6,17 +6,14 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { Button, VisuallyHidden } from '@wordpress/components';
10
- import { useInstanceId } from '@wordpress/compose';
9
+ import { Button } from '@wordpress/components';
11
10
  import { forwardRef } from '@wordpress/element';
12
- import { __ } from '@wordpress/i18n';
13
11
 
14
12
  /**
15
13
  * Internal dependencies
16
14
  */
17
15
  import BlockIcon from '../block-icon';
18
16
  import useBlockDisplayInformation from '../use-block-display-information';
19
- import { getBlockPositionDescription } from './utils';
20
17
  import BlockTitle from '../block-title';
21
18
  import ListViewExpander from './expander';
22
19
  import { SPACE, ENTER } from '@wordpress/keycodes';
@@ -25,29 +22,17 @@ function ListViewBlockSelectButton(
25
22
  {
26
23
  className,
27
24
  block: { clientId },
28
- isSelected,
29
25
  onClick,
30
26
  onToggleExpanded,
31
- position,
32
- siblingBlockCount,
33
- level,
34
27
  tabIndex,
35
28
  onFocus,
36
29
  onDragStart,
37
30
  onDragEnd,
38
31
  draggable,
39
- isExpanded,
40
32
  },
41
33
  ref
42
34
  ) {
43
35
  const blockInformation = useBlockDisplayInformation( clientId );
44
- const instanceId = useInstanceId( ListViewBlockSelectButton );
45
- const descriptionId = `list-view-block-select-button__${ instanceId }`;
46
- const blockPositionDescription = getBlockPositionDescription(
47
- position,
48
- siblingBlockCount,
49
- level
50
- );
51
36
 
52
37
  // The `href` attribute triggers the browser's native HTML drag operations.
53
38
  // When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
@@ -73,7 +58,6 @@ function ListViewBlockSelectButton(
73
58
  ) }
74
59
  onClick={ onClick }
75
60
  onKeyDown={ onKeyDownHandler }
76
- aria-describedby={ descriptionId }
77
61
  ref={ ref }
78
62
  tabIndex={ tabIndex }
79
63
  onFocus={ onFocus }
@@ -81,7 +65,7 @@ function ListViewBlockSelectButton(
81
65
  onDragEnd={ onDragEnd }
82
66
  draggable={ draggable }
83
67
  href={ `#block-${ clientId }` }
84
- aria-expanded={ isExpanded }
68
+ aria-hidden={ true }
85
69
  >
86
70
  <ListViewExpander onClick={ onToggleExpanded } />
87
71
  <BlockIcon icon={ blockInformation?.icon } showColors />
@@ -91,18 +75,7 @@ function ListViewBlockSelectButton(
91
75
  { blockInformation.anchor }
92
76
  </span>
93
77
  ) }
94
- { isSelected && (
95
- <VisuallyHidden>
96
- { __( '(selected block)' ) }
97
- </VisuallyHidden>
98
- ) }
99
78
  </Button>
100
- <div
101
- className="block-editor-list-view-block-select-button__description"
102
- id={ descriptionId }
103
- >
104
- { blockPositionDescription }
105
- </div>
106
79
  </>
107
80
  );
108
81
  }
@@ -10,6 +10,7 @@ import {
10
10
  __experimentalTreeGridCell as TreeGridCell,
11
11
  __experimentalTreeGridItem as TreeGridItem,
12
12
  } from '@wordpress/components';
13
+ import { useInstanceId } from '@wordpress/compose';
13
14
  import { moreVertical } from '@wordpress/icons';
14
15
  import {
15
16
  useState,
@@ -32,6 +33,7 @@ import {
32
33
  import ListViewBlockContents from './block-contents';
33
34
  import BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';
34
35
  import { useListViewContext } from './context';
36
+ import { getBlockPositionDescription } from './utils';
35
37
  import { store as blockEditorStore } from '../../store';
36
38
  import useBlockDisplayInformation from '../use-block-display-information';
37
39
 
@@ -49,6 +51,7 @@ function ListViewBlock( {
49
51
  path,
50
52
  isExpanded,
51
53
  selectedClientIds,
54
+ preventAnnouncement,
52
55
  } ) {
53
56
  const cellRef = useRef( null );
54
57
  const [ isHovered, setIsHovered ] = useState( false );
@@ -56,6 +59,31 @@ function ListViewBlock( {
56
59
 
57
60
  const { toggleBlockHighlight } = useDispatch( blockEditorStore );
58
61
 
62
+ const blockInformation = useBlockDisplayInformation( clientId );
63
+ const instanceId = useInstanceId( ListViewBlock );
64
+ const descriptionId = `list-view-block-select-button__${ instanceId }`;
65
+ const blockPositionDescription = getBlockPositionDescription(
66
+ position,
67
+ siblingBlockCount,
68
+ level
69
+ );
70
+
71
+ const blockAriaLabel = blockInformation
72
+ ? sprintf(
73
+ // translators: %s: The title of the block. This string indicates a link to select the block.
74
+ __( '%s link' ),
75
+ blockInformation.title
76
+ )
77
+ : __( 'Link' );
78
+
79
+ const settingsAriaLabel = blockInformation
80
+ ? sprintf(
81
+ // translators: %s: The title of the block.
82
+ __( 'Options for %s block' ),
83
+ blockInformation.title
84
+ )
85
+ : __( 'Options' );
86
+
59
87
  const {
60
88
  __experimentalFeatures: withExperimentalFeatures,
61
89
  __experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,
@@ -106,11 +134,12 @@ function ListViewBlock( {
106
134
  const selectEditorBlock = useCallback(
107
135
  ( event ) => {
108
136
  selectBlock( event, clientId );
137
+ event.preventDefault();
109
138
  },
110
139
  [ clientId, selectBlock ]
111
140
  );
112
141
 
113
- const selectDuplicatedBlock = useCallback(
142
+ const updateSelection = useCallback(
114
143
  ( newClientId ) => {
115
144
  selectBlock( undefined, newClientId );
116
145
  },
@@ -154,15 +183,6 @@ function ListViewBlock( {
154
183
  'has-single-cell': hideBlockActions,
155
184
  } );
156
185
 
157
- const blockInformation = useBlockDisplayInformation( clientId );
158
- const settingsAriaLabel = blockInformation
159
- ? sprintf(
160
- // translators: %s: The title of the block.
161
- __( 'Options for %s block' ),
162
- blockInformation.title
163
- )
164
- : __( 'Options' );
165
-
166
186
  // Only include all selected blocks if the currently clicked on block
167
187
  // is one of the selected blocks. This ensures that if a user attempts
168
188
  // to alter a block that isn't part of the selection, they're still able
@@ -185,11 +205,16 @@ function ListViewBlock( {
185
205
  id={ `list-view-block-${ clientId }` }
186
206
  data-block={ clientId }
187
207
  isExpanded={ isExpanded }
208
+ aria-selected={ !! isSelected }
188
209
  >
189
210
  <TreeGridCell
190
211
  className="block-editor-list-view-block__contents-cell"
191
212
  colSpan={ colSpan }
192
213
  ref={ cellRef }
214
+ aria-label={ blockAriaLabel }
215
+ aria-selected={ !! isSelected }
216
+ aria-expanded={ isExpanded }
217
+ aria-describedby={ descriptionId }
193
218
  >
194
219
  { ( { ref, tabIndex, onFocus } ) => (
195
220
  <div className="block-editor-list-view-block__contents-container">
@@ -206,7 +231,14 @@ function ListViewBlock( {
206
231
  onFocus={ onFocus }
207
232
  isExpanded={ isExpanded }
208
233
  selectedClientIds={ selectedClientIds }
234
+ preventAnnouncement={ preventAnnouncement }
209
235
  />
236
+ <div
237
+ className="block-editor-list-view-block-select-button__description"
238
+ id={ descriptionId }
239
+ >
240
+ { blockPositionDescription }
241
+ </div>
210
242
  </div>
211
243
  ) }
212
244
  </TreeGridCell>
@@ -243,7 +275,10 @@ function ListViewBlock( {
243
275
  ) }
244
276
 
245
277
  { showBlockActions && (
246
- <TreeGridCell className={ listViewBlockSettingsClassName }>
278
+ <TreeGridCell
279
+ className={ listViewBlockSettingsClassName }
280
+ aria-selected={ !! isSelected }
281
+ >
247
282
  { ( { ref, tabIndex, onFocus } ) => (
248
283
  <BlockSettingsDropdown
249
284
  clientIds={ dropdownClientIds }
@@ -256,7 +291,7 @@ function ListViewBlock( {
256
291
  onFocus,
257
292
  } }
258
293
  disableOpenOnArrowDown
259
- __experimentalSelectBlock={ selectDuplicatedBlock }
294
+ __experimentalSelectBlock={ updateSelection }
260
295
  />
261
296
  ) }
262
297
  </TreeGridCell>