@wordpress/edit-site 6.25.0 → 6.26.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 (32) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/add-custom-generic-template-modal-content.js +13 -6
  3. package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
  4. package/build/components/add-new-template/add-custom-template-modal-content.js +37 -1
  5. package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
  6. package/build/components/add-new-template/index.js +16 -3
  7. package/build/components/add-new-template/index.js.map +1 -1
  8. package/build/components/global-styles/font-sizes/font-sizes.js +1 -2
  9. package/build/components/global-styles/font-sizes/font-sizes.js.map +1 -1
  10. package/build/components/global-styles/shadows-edit-panel.js +3 -7
  11. package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
  12. package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js +14 -7
  13. package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -1
  14. package/build-module/components/add-new-template/add-custom-template-modal-content.js +37 -1
  15. package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -1
  16. package/build-module/components/add-new-template/index.js +17 -4
  17. package/build-module/components/add-new-template/index.js.map +1 -1
  18. package/build-module/components/global-styles/font-sizes/font-sizes.js +1 -2
  19. package/build-module/components/global-styles/font-sizes/font-sizes.js.map +1 -1
  20. package/build-module/components/global-styles/shadows-edit-panel.js +3 -7
  21. package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
  22. package/build-style/posts-rtl.css +6 -6
  23. package/build-style/posts.css +6 -6
  24. package/build-style/style-rtl.css +8 -7
  25. package/build-style/style.css +8 -7
  26. package/package.json +42 -42
  27. package/src/components/add-new-template/add-custom-generic-template-modal-content.js +14 -6
  28. package/src/components/add-new-template/add-custom-template-modal-content.js +45 -1
  29. package/src/components/add-new-template/index.js +25 -3
  30. package/src/components/global-styles/font-sizes/font-sizes.js +2 -2
  31. package/src/components/global-styles/shadows-edit-panel.js +1 -6
  32. package/src/components/global-styles/style.scss +2 -1
@@ -16,6 +16,7 @@ import {
16
16
  import { useEntityRecords } from '@wordpress/core-data';
17
17
  import { decodeEntities } from '@wordpress/html-entities';
18
18
  import { useDebouncedInput } from '@wordpress/compose';
19
+ import { focus } from '@wordpress/dom';
19
20
 
20
21
  /**
21
22
  * Internal dependencies
@@ -165,10 +166,27 @@ function SuggestionList( { entityForSuggestions, onSelect } ) {
165
166
  );
166
167
  }
167
168
 
168
- function AddCustomTemplateModalContent( { onSelect, entityForSuggestions } ) {
169
+ function AddCustomTemplateModalContent( {
170
+ onSelect,
171
+ entityForSuggestions,
172
+ onBack,
173
+ containerRef,
174
+ } ) {
169
175
  const [ showSearchEntities, setShowSearchEntities ] = useState(
170
176
  entityForSuggestions.hasGeneralTemplate
171
177
  );
178
+
179
+ // Focus on the first focusable element when the modal opens.
180
+ // We handle focus management in the parent modal, just need to focus on the first focusable element.
181
+ useEffect( () => {
182
+ if ( containerRef.current ) {
183
+ const [ firstFocusable ] = focus.focusable.find(
184
+ containerRef.current
185
+ );
186
+ firstFocusable?.focus();
187
+ }
188
+ }, [ showSearchEntities ] );
189
+
172
190
  return (
173
191
  <VStack
174
192
  spacing={ 4 }
@@ -247,6 +265,15 @@ function AddCustomTemplateModalContent( { onSelect, entityForSuggestions } ) {
247
265
  </Text>
248
266
  </FlexItem>
249
267
  </Flex>
268
+ <Flex justify="right">
269
+ <Button
270
+ __next40pxDefaultSize
271
+ variant="tertiary"
272
+ onClick={ onBack }
273
+ >
274
+ { __( 'Back' ) }
275
+ </Button>
276
+ </Flex>
250
277
  </>
251
278
  ) }
252
279
  { showSearchEntities && (
@@ -260,6 +287,23 @@ function AddCustomTemplateModalContent( { onSelect, entityForSuggestions } ) {
260
287
  entityForSuggestions={ entityForSuggestions }
261
288
  onSelect={ onSelect }
262
289
  />
290
+ <Flex justify="right">
291
+ <Button
292
+ __next40pxDefaultSize
293
+ variant="tertiary"
294
+ onClick={ () => {
295
+ // If general template exists, go directly back to main screen
296
+ // instead of showing the choice screen
297
+ if ( entityForSuggestions.hasGeneralTemplate ) {
298
+ onBack();
299
+ } else {
300
+ setShowSearchEntities( false );
301
+ }
302
+ } }
303
+ >
304
+ { __( 'Back' ) }
305
+ </Button>
306
+ </Flex>
263
307
  </>
264
308
  ) }
265
309
  </VStack>
@@ -16,7 +16,7 @@ import {
16
16
  Icon,
17
17
  } from '@wordpress/components';
18
18
  import { decodeEntities } from '@wordpress/html-entities';
19
- import { useState, memo } from '@wordpress/element';
19
+ import { useState, memo, useRef, useEffect } from '@wordpress/element';
20
20
  import { useSelect, useDispatch } from '@wordpress/data';
21
21
  import { store as coreStore } from '@wordpress/core-data';
22
22
  import { useViewportMatch } from '@wordpress/compose';
@@ -41,6 +41,7 @@ import {
41
41
  import { __, sprintf } from '@wordpress/i18n';
42
42
  import { store as noticesStore } from '@wordpress/notices';
43
43
  import { privateApis as routerPrivateApis } from '@wordpress/router';
44
+ import { focus } from '@wordpress/dom';
44
45
 
45
46
  /**
46
47
  * Internal dependencies
@@ -162,7 +163,7 @@ function NewTemplateModal( { onClose } ) {
162
163
  const { saveEntityRecord } = useDispatch( coreStore );
163
164
  const { createErrorNotice, createSuccessNotice } =
164
165
  useDispatch( noticesStore );
165
-
166
+ const containerRef = useRef( null );
166
167
  const isMobile = useViewportMatch( 'medium', '<' );
167
168
 
168
169
  const homeUrl = useSelect( ( select ) => {
@@ -180,6 +181,20 @@ function NewTemplateModal( { onClose } ) {
180
181
  ),
181
182
  };
182
183
 
184
+ useEffect( () => {
185
+ // Focus the first focusable element when component mounts or UI changes
186
+ // We don't want to focus on the other modals because they have their own focus management.
187
+ if (
188
+ containerRef.current &&
189
+ modalContent === modalContentMap.templatesList
190
+ ) {
191
+ const [ firstFocusable ] = focus.focusable.find(
192
+ containerRef.current
193
+ );
194
+ firstFocusable?.focus();
195
+ }
196
+ }, [ modalContent ] );
197
+
183
198
  async function createTemplate( template, isWPSuggestion = true ) {
184
199
  if ( isSubmitting ) {
185
200
  return;
@@ -261,6 +276,7 @@ function NewTemplateModal( { onClose } ) {
261
276
  ? 'edit-site-custom-generic-template__modal'
262
277
  : undefined
263
278
  }
279
+ ref={ containerRef }
264
280
  >
265
281
  { modalContent === modalContentMap.templatesList && (
266
282
  <Grid
@@ -320,12 +336,18 @@ function NewTemplateModal( { onClose } ) {
320
336
  <AddCustomTemplateModalContent
321
337
  onSelect={ createTemplate }
322
338
  entityForSuggestions={ entityForSuggestions }
339
+ onBack={ () =>
340
+ setModalContent( modalContentMap.templatesList )
341
+ }
342
+ containerRef={ containerRef }
323
343
  />
324
344
  ) }
325
345
  { modalContent === modalContentMap.customGenericTemplate && (
326
346
  <AddCustomGenericTemplateModalContent
327
- onClose={ onModalClose }
328
347
  createTemplate={ createTemplate }
348
+ onBack={ () =>
349
+ setModalContent( modalContentMap.templatesList )
350
+ }
329
351
  />
330
352
  ) }
331
353
  </Modal>
@@ -69,9 +69,9 @@ function FontSizeGroup( {
69
69
  />
70
70
  ) }
71
71
  <VStack spacing={ 4 }>
72
- <HStack justify="space-between" align="center">
72
+ <HStack>
73
73
  <Subtitle level={ 3 }>{ label }</Subtitle>
74
- <FlexItem>
74
+ <FlexItem className="edit-site-global-styles__typography-panel__options-container">
75
75
  { origin === 'custom' && (
76
76
  <Button
77
77
  label={ __( 'Add font size' ) }
@@ -327,12 +327,7 @@ function ShadowEditor( { shadow, onChange } ) {
327
327
  <>
328
328
  <VStack spacing={ 2 }>
329
329
  <HStack justify="space-between">
330
- <Flex
331
- align="center"
332
- className="edit-site-global-styles__shadows-panel__title"
333
- >
334
- <Subtitle level={ 3 }>{ __( 'Shadows' ) }</Subtitle>
335
- </Flex>
330
+ <Subtitle level={ 3 }>{ __( 'Shadows' ) }</Subtitle>
336
331
  <FlexItem className="edit-site-global-styles__shadows-panel__options-container">
337
332
  <Button
338
333
  size="small"
@@ -104,7 +104,8 @@
104
104
  flex-shrink: 0;
105
105
  }
106
106
 
107
- .edit-site-global-styles__shadows-panel__options-container {
107
+ .edit-site-global-styles__shadows-panel__options-container,
108
+ .edit-site-global-styles__typography-panel__options-container {
108
109
  height: $grid-unit * 3;
109
110
  }
110
111