Skip to content

Commit

Permalink
Font Library Modal: Reset the selected font when installing a new font (
Browse files Browse the repository at this point in the history
#57817)

* Reset the selected font when installing a new font

* Use setLibraryFontSelected directly

* Add finally block to installFonts

* Move setLibraryFontSelected to success block

* Set library selected font in installed-fonts useEffect
  • Loading branch information
mikachan authored Jan 15, 2024
1 parent 5a5da27 commit a85fbc4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,13 @@ function FontLibraryProvider( { children } ) {
'settings.typography.fontFamilies',
] );
refreshLibrary();
setIsInstalling( false );

return response;
} catch ( error ) {
setIsInstalling( false );
return {
errors: [ error ],
};
} finally {
setIsInstalling( false );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function InstalledFonts() {
!! libraryFontSelected && libraryFontSelected?.source !== 'theme';

useEffect( () => {
handleSelectFont( libraryFontSelected );
refreshLibrary();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [] );
Expand Down

0 comments on commit a85fbc4

Please sign in to comment.