Skip to content

Code Quality: fix browser deprecation warning #762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/editor-sidebar/create-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const CreateThemePanel = ( { createType } ) => {
<VStack>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Theme name', 'create-block-theme' ) }
value={ theme.name }
onChange={ ( value ) =>
Expand Down Expand Up @@ -163,6 +164,7 @@ export const CreateThemePanel = ( { createType } ) => {
/>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Theme URI', 'create-block-theme' ) }
value={ theme.uri }
onChange={ ( value ) =>
Expand All @@ -175,6 +177,7 @@ export const CreateThemePanel = ( { createType } ) => {
/>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Author', 'create-block-theme' ) }
value={ theme.author }
onChange={ ( value ) =>
Expand All @@ -187,6 +190,7 @@ export const CreateThemePanel = ( { createType } ) => {
/>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Author URI', 'create-block-theme' ) }
value={ theme.author_uri }
onChange={ ( value ) =>
Expand All @@ -199,6 +203,7 @@ export const CreateThemePanel = ( { createType } ) => {
/>
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __(
'Minimum WordPress version',
'create-block-theme'
Expand Down
1 change: 1 addition & 0 deletions src/editor-sidebar/create-variation-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const CreateVariationPanel = () => {
<VStack spacing={ 4 }>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __(
'Variation name',
'create-block-theme'
Expand Down
67 changes: 48 additions & 19 deletions src/editor-sidebar/metadata-editor-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
import { useState, useEffect } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as noticesStore } from '@wordpress/notices';
import {
Expand Down Expand Up @@ -60,25 +60,47 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {

const { createErrorNotice } = useDispatch( noticesStore );

useSelect( async ( select ) => {
const themeData = select( 'core' ).getCurrentTheme();
const readmeData = await fetchReadmeData();
const themeData = useSelect(
( select ) => select( 'core' ).getCurrentTheme(),
[]
);

useEffect( () => {
if ( ! themeData ) {
return;
}

const fetchData = async () => {
try {
const readmeData = await fetchReadmeData();
setTheme( {
name: themeData.name.raw,
description: themeData.description.raw,
uri: themeData.theme_uri.raw,
version: themeData.version,
requires_wp: themeData.requires_wp,
author: themeData.author.raw,
author_uri: themeData.author_uri.raw,
tags_custom: themeData.tags.rendered,
screenshot: themeData.screenshot,
recommended_plugins: readmeData.recommended_plugins,
font_credits: readmeData.fonts,
image_credits: readmeData.images,
} );
} catch ( error ) {
createErrorNotice(
error.message ||
__(
'Failed to fetch theme data.',
'create-block-theme'
),
{ type: 'snackbar' }
);
}
};

setTheme( {
name: themeData.name.raw,
description: themeData.description.raw,
uri: themeData.theme_uri.raw,
version: themeData.version,
requires_wp: themeData.requires_wp,
author: themeData.author.raw,
author_uri: themeData.author_uri.raw,
tags_custom: themeData.tags.rendered,
screenshot: themeData.screenshot,
recommended_plugins: readmeData.recommended_plugins,
font_credits: readmeData.fonts,
image_credits: readmeData.images,
} );
}, [] );
fetchData();
}, [ themeData, createErrorNotice ] );

const handleUpdateClick = () => {
postUpdateThemeMetadata( theme )
Expand Down Expand Up @@ -152,6 +174,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
<Spacer />
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
disabled
label={ __( 'Theme name', 'create-block-theme' ) }
value={ theme.name }
Expand All @@ -170,6 +193,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
/>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Theme URI', 'create-block-theme' ) }
value={ theme.uri }
onChange={ ( value ) =>
Expand All @@ -182,6 +206,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
/>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Author', 'create-block-theme' ) }
value={ theme.author }
onChange={ ( value ) =>
Expand All @@ -194,6 +219,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
/>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Author URI', 'create-block-theme' ) }
value={ theme.author_uri }
onChange={ ( value ) =>
Expand All @@ -206,6 +232,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
/>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Version', 'create-block-theme' ) }
value={ theme.version }
onChange={ ( value ) =>
Expand All @@ -218,6 +245,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
/>
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __(
'Minimum WordPress version',
'create-block-theme'
Expand All @@ -233,6 +261,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
/>
<FormTokenField
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Theme tags', 'create-block-theme' ) }
value={
theme.tags_custom ? theme.tags_custom.split( ', ' ) : []
Expand Down
6 changes: 5 additions & 1 deletion src/editor-sidebar/screen-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import {
Navigator,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalHStack as HStack,
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
Expand All @@ -15,10 +16,13 @@ import { isRTL, __ } from '@wordpress/i18n';
import { chevronRight, chevronLeft } from '@wordpress/icons';

const ScreenHeader = ( { title, onBack } ) => {
// TODO: Remove the fallback component when the minimum supported WordPress
// version was increased to 6.7.
const BackButton = Navigator?.BackButton || NavigatorToParentButton;
return (
<Spacer marginBottom={ 0 } paddingBottom={ 4 }>
<HStack spacing={ 2 }>
<NavigatorToParentButton
<BackButton
style={ { minWidth: 24, padding: 0 } }
icon={ isRTL() ? chevronRight : chevronLeft }
size="small"
Expand Down
2 changes: 2 additions & 0 deletions src/landing-page/create-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export const CreateThemeModal = ( { onRequestClose, creationType } ) => {
</Text>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __(
'Theme name (required)',
'create-block-theme'
Expand Down Expand Up @@ -140,6 +141,7 @@ export const CreateThemeModal = ( { onRequestClose, creationType } ) => {
/>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Author', 'create-block-theme' ) }
value={ theme.author }
onChange={ ( value ) =>
Expand Down