Skip to content

Commit b37d0bc

Browse files
committed
Code Quality: fix browser deprecation warning
1 parent cac02eb commit b37d0bc

File tree

5 files changed

+61
-20
lines changed

5 files changed

+61
-20
lines changed

src/editor-sidebar/create-panel.js

+5
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export const CreateThemePanel = ( { createType } ) => {
131131
<VStack>
132132
<TextControl
133133
__nextHasNoMarginBottom
134+
__next40pxDefaultSize
134135
label={ __( 'Theme name', 'create-block-theme' ) }
135136
value={ theme.name }
136137
onChange={ ( value ) =>
@@ -163,6 +164,7 @@ export const CreateThemePanel = ( { createType } ) => {
163164
/>
164165
<TextControl
165166
__nextHasNoMarginBottom
167+
__next40pxDefaultSize
166168
label={ __( 'Theme URI', 'create-block-theme' ) }
167169
value={ theme.uri }
168170
onChange={ ( value ) =>
@@ -175,6 +177,7 @@ export const CreateThemePanel = ( { createType } ) => {
175177
/>
176178
<TextControl
177179
__nextHasNoMarginBottom
180+
__next40pxDefaultSize
178181
label={ __( 'Author', 'create-block-theme' ) }
179182
value={ theme.author }
180183
onChange={ ( value ) =>
@@ -187,6 +190,7 @@ export const CreateThemePanel = ( { createType } ) => {
187190
/>
188191
<TextControl
189192
__nextHasNoMarginBottom
193+
__next40pxDefaultSize
190194
label={ __( 'Author URI', 'create-block-theme' ) }
191195
value={ theme.author_uri }
192196
onChange={ ( value ) =>
@@ -199,6 +203,7 @@ export const CreateThemePanel = ( { createType } ) => {
199203
/>
200204
<SelectControl
201205
__nextHasNoMarginBottom
206+
__next40pxDefaultSize
202207
label={ __(
203208
'Minimum WordPress version',
204209
'create-block-theme'

src/editor-sidebar/create-variation-panel.js

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export const CreateVariationPanel = () => {
104104
<VStack spacing={ 4 }>
105105
<TextControl
106106
__nextHasNoMarginBottom
107+
__next40pxDefaultSize
107108
label={ __(
108109
'Variation name',
109110
'create-block-theme'

src/editor-sidebar/metadata-editor-modal.js

+48-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* WordPress dependencies
33
*/
44
import { __, sprintf } from '@wordpress/i18n';
5-
import { useState } from '@wordpress/element';
5+
import { useState, useEffect } from '@wordpress/element';
66
import { useSelect, useDispatch } from '@wordpress/data';
77
import { store as noticesStore } from '@wordpress/notices';
88
import {
@@ -60,25 +60,47 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
6060

6161
const { createErrorNotice } = useDispatch( noticesStore );
6262

63-
useSelect( async ( select ) => {
64-
const themeData = select( 'core' ).getCurrentTheme();
65-
const readmeData = await fetchReadmeData();
63+
const themeData = useSelect(
64+
( select ) => select( 'core' ).getCurrentTheme(),
65+
[]
66+
);
67+
68+
useEffect( () => {
69+
if ( ! themeData ) {
70+
return;
71+
}
72+
73+
const fetchData = async () => {
74+
try {
75+
const readmeData = await fetchReadmeData();
76+
setTheme( {
77+
name: themeData.name.raw,
78+
description: themeData.description.raw,
79+
uri: themeData.theme_uri.raw,
80+
version: themeData.version,
81+
requires_wp: themeData.requires_wp,
82+
author: themeData.author.raw,
83+
author_uri: themeData.author_uri.raw,
84+
tags_custom: themeData.tags.rendered,
85+
screenshot: themeData.screenshot,
86+
recommended_plugins: readmeData.recommended_plugins,
87+
font_credits: readmeData.fonts,
88+
image_credits: readmeData.images,
89+
} );
90+
} catch ( error ) {
91+
createErrorNotice(
92+
error.message ||
93+
__(
94+
'Failed to fetch theme data.',
95+
'create-block-theme'
96+
),
97+
{ type: 'snackbar' }
98+
);
99+
}
100+
};
66101

67-
setTheme( {
68-
name: themeData.name.raw,
69-
description: themeData.description.raw,
70-
uri: themeData.theme_uri.raw,
71-
version: themeData.version,
72-
requires_wp: themeData.requires_wp,
73-
author: themeData.author.raw,
74-
author_uri: themeData.author_uri.raw,
75-
tags_custom: themeData.tags.rendered,
76-
screenshot: themeData.screenshot,
77-
recommended_plugins: readmeData.recommended_plugins,
78-
font_credits: readmeData.fonts,
79-
image_credits: readmeData.images,
80-
} );
81-
}, [] );
102+
fetchData();
103+
}, [ themeData, createErrorNotice ] );
82104

83105
const handleUpdateClick = () => {
84106
postUpdateThemeMetadata( theme )
@@ -152,6 +174,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
152174
<Spacer />
153175
<TextControl
154176
__nextHasNoMarginBottom
177+
__next40pxDefaultSize
155178
disabled
156179
label={ __( 'Theme name', 'create-block-theme' ) }
157180
value={ theme.name }
@@ -170,6 +193,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
170193
/>
171194
<TextControl
172195
__nextHasNoMarginBottom
196+
__next40pxDefaultSize
173197
label={ __( 'Theme URI', 'create-block-theme' ) }
174198
value={ theme.uri }
175199
onChange={ ( value ) =>
@@ -182,6 +206,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
182206
/>
183207
<TextControl
184208
__nextHasNoMarginBottom
209+
__next40pxDefaultSize
185210
label={ __( 'Author', 'create-block-theme' ) }
186211
value={ theme.author }
187212
onChange={ ( value ) =>
@@ -194,6 +219,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
194219
/>
195220
<TextControl
196221
__nextHasNoMarginBottom
222+
__next40pxDefaultSize
197223
label={ __( 'Author URI', 'create-block-theme' ) }
198224
value={ theme.author_uri }
199225
onChange={ ( value ) =>
@@ -206,6 +232,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
206232
/>
207233
<TextControl
208234
__nextHasNoMarginBottom
235+
__next40pxDefaultSize
209236
label={ __( 'Version', 'create-block-theme' ) }
210237
value={ theme.version }
211238
onChange={ ( value ) =>
@@ -218,6 +245,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
218245
/>
219246
<SelectControl
220247
__nextHasNoMarginBottom
248+
__next40pxDefaultSize
221249
label={ __(
222250
'Minimum WordPress version',
223251
'create-block-theme'
@@ -233,6 +261,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
233261
/>
234262
<FormTokenField
235263
__nextHasNoMarginBottom
264+
__next40pxDefaultSize
236265
label={ __( 'Theme tags', 'create-block-theme' ) }
237266
value={
238267
theme.tags_custom ? theme.tags_custom.split( ', ' ) : []

src/editor-sidebar/screen-header.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* WordPress dependencies
33
*/
44
import {
5+
Navigator,
56
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
67
__experimentalHStack as HStack,
78
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
@@ -15,10 +16,13 @@ import { isRTL, __ } from '@wordpress/i18n';
1516
import { chevronRight, chevronLeft } from '@wordpress/icons';
1617

1718
const ScreenHeader = ( { title, onBack } ) => {
19+
// TODO: Remove the fallback component when the minimum supported WordPress
20+
// version was increased to 6.7.
21+
const BackButton = Navigator?.BackButton || NavigatorToParentButton;
1822
return (
1923
<Spacer marginBottom={ 0 } paddingBottom={ 4 }>
2024
<HStack spacing={ 2 }>
21-
<NavigatorToParentButton
25+
<BackButton
2226
style={ { minWidth: 24, padding: 0 } }
2327
icon={ isRTL() ? chevronRight : chevronLeft }
2428
size="small"

src/landing-page/create-modal.js

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export const CreateThemeModal = ( { onRequestClose, creationType } ) => {
112112
</Text>
113113
<TextControl
114114
__nextHasNoMarginBottom
115+
__next40pxDefaultSize
115116
label={ __(
116117
'Theme name (required)',
117118
'create-block-theme'
@@ -140,6 +141,7 @@ export const CreateThemeModal = ( { onRequestClose, creationType } ) => {
140141
/>
141142
<TextControl
142143
__nextHasNoMarginBottom
144+
__next40pxDefaultSize
143145
label={ __( 'Author', 'create-block-theme' ) }
144146
value={ theme.author }
145147
onChange={ ( value ) =>

0 commit comments

Comments
 (0)