Skip to content

Commit

Permalink
Font Library: Fix focus loss when update/install button is pressed (#…
Browse files Browse the repository at this point in the history
…58364)

* Font Library: Fix focus loss when update/install button is pressed

* Add undefined
  • Loading branch information
t-hamano authored Jan 30, 2024
1 parent 2b608f9 commit c564ece
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ function FontCollection( { slug } ) {
notice={ notice }
handleBack={ !! selectedFont && handleUnselectFont }
footer={
fontsToInstall.length > 0 && (
<Footer handleInstall={ handleInstall } />
)
<Footer
handleInstall={ handleInstall }
isDisabled={ fontsToInstall.length === 0 }
/>
}
>
{ renderConfirmDialog && (
Expand Down Expand Up @@ -290,16 +291,18 @@ function FontCollection( { slug } ) {
);
}

function Footer( { handleInstall } ) {
function Footer( { handleInstall, isDisabled } ) {
const { isInstalling } = useContext( FontLibraryContext );

return (
<Flex justify="flex-end">
<Button
variant="primary"
onClick={ handleInstall }
onClick={
isDisabled || isInstalling ? undefined : handleInstall
}
isBusy={ isInstalling }
disabled={ isInstalling }
aria-disabled={ isDisabled || isInstalling }
>
{ __( 'Install' ) }
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ function Footer( { shouldDisplayDeleteButton, handleUninstallClick } ) {
) }
</div>
<Button
disabled={ ! fontFamiliesHasChanges }
aria-disabled={ ! fontFamiliesHasChanges }
variant="primary"
onClick={ saveFontFamilies }
onClick={
fontFamiliesHasChanges ? saveFontFamilies : undefined
}
>
{ __( 'Update' ) }
</Button>
Expand Down

1 comment on commit c564ece

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in c564ece.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7711066055
📝 Reported issues:

Please sign in to comment.