diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/context.js b/packages/edit-site/src/components/global-styles/font-library-modal/context.js index 2b9efd2ddccd6..04eabb149f5f4 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/context.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/context.js @@ -61,15 +61,6 @@ function FontLibraryProvider( { children } ) { setRefreshKey( Date.now() ); }; - // Reset notice on dismiss. - useEffect( () => { - if ( notice ) { - notice.onRemove = () => { - setNotice( null ); - }; - } - }, [ notice, setNotice ] ); - const { records: libraryPosts = [], isResolving: isResolvingLibrary, diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js b/packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js index 7250e0a745ce5..c959a5373190e 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js @@ -1,6 +1,7 @@ /** * WordPress dependencies */ +import { useContext } from '@wordpress/element'; import { __experimentalText as Text, __experimentalHeading as Heading, @@ -14,6 +15,11 @@ import { import { chevronLeft } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; +/** + * Internal dependencies + */ +import { FontLibraryContext } from './context'; + function TabPanelLayout( { title, description, @@ -22,6 +28,8 @@ function TabPanelLayout( { children, footer, } ) { + const { setNotice } = useContext( FontLibraryContext ); + return (
@@ -53,7 +61,7 @@ function TabPanelLayout( { setNotice( null ) } > { notice.message } diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js b/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js index c956b0d55e691..a40534861ae96 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js @@ -63,6 +63,12 @@ function UploadFonts() { } ); if ( allowedFiles.length > 0 ) { loadFiles( allowedFiles ); + } else { + setNotice( { + type: 'error', + message: __( 'No fonts found to install.' ), + } ); + setIsUploading( false ); } };