Skip to content
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

Font Library: make the notices manually dismisable #58178

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,6 @@ function FontCollection( { slug } ) {
setFontsToInstall( [] );
}, [ selectedFont ] );

// Reset notice after 5 seconds
useEffect( () => {
if ( notice && notice?.duration !== 0 ) {
const timeout = setTimeout( () => {
setNotice( null );
}, notice.duration ?? 5000 );
return () => clearTimeout( timeout );
}
}, [ notice ] );

const collectionFonts = useMemo(
() => selectedCollection?.font_families ?? [],
[ selectedCollection ]
Expand Down Expand Up @@ -224,9 +214,9 @@ function FontCollection( { slug } ) {
<FlexItem>
<Spacer margin={ 2 } />
<Notice
isDismissible={ false }
status={ notice.type }
className="font-library-modal__font-collection__notice"
onRemove={ () => setNotice( null ) }
>
{ notice.message }
</Notice>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function InstalledFonts() {
message: __( 'Font family uninstalled successfully.' ),
} );

// If the font was succesfully uninstalled it is unselected.
// If the font was successfully uninstalled it is unselected.
handleUnselectFont();
setIsConfirmDeleteOpen( false );
} catch ( error ) {
Expand Down Expand Up @@ -91,16 +91,6 @@ function InstalledFonts() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [] );

// Reset notice after 5 seconds
useEffect( () => {
if ( notice ) {
const timeout = setTimeout( () => {
setNotice( null );
}, 5000 );
return () => clearTimeout( timeout );
}
}, [ notice ] );

return (
<TabPanelLayout
title={ libraryFontSelected?.name || '' }
Expand All @@ -125,9 +115,9 @@ function InstalledFonts() {
<FlexItem>
<Spacer margin={ 2 } />
<Notice
isDismissible={ false }
status={ notice.type }
className="font-library-modal__font-collection__notice"
onRemove={ () => setNotice( null ) }
>
{ notice.message }
</Notice>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
FlexItem,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { useContext, useState, useEffect } from '@wordpress/element';
import { useContext, useState } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -44,16 +44,6 @@ function LocalFonts() {
handleFilesUpload( event.target.files );
};

// Reset notice after 5 seconds
useEffect( () => {
if ( notice ) {
const timeout = setTimeout( () => {
setNotice( null );
}, 5000 );
return () => clearTimeout( timeout );
}
}, [ notice ] );

/**
* Filters the selected files to only allow the ones with the allowed extensions
*
Expand Down Expand Up @@ -223,9 +213,9 @@ function LocalFonts() {
<FlexItem>
<Spacer margin={ 2 } />
<Notice
isDismissible={ false }
status={ notice.type }
className="font-library-modal__upload-area__notice"
onRemove={ () => setNotice( null ) }
>
{ notice.message }
</Notice>
Expand Down
Loading