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: Fix focus loss when update/install button is pressed #58364

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -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,7 +291,7 @@ function FontCollection( { slug } ) {
);
}

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

return (
Expand All @@ -299,7 +300,7 @@ function Footer( { handleInstall } ) {
variant="primary"
onClick={ handleInstall }
Copy link
Contributor

Choose a reason for hiding this comment

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

The button should be noop'ed when isDisabled || isInstalling

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,7 +186,7 @@ function Footer( { shouldDisplayDeleteButton, handleUninstallClick } ) {
) }
</div>
<Button
disabled={ ! fontFamiliesHasChanges }
aria-disabled={ ! fontFamiliesHasChanges }
variant="primary"
onClick={ saveFontFamilies }
Copy link
Contributor

Choose a reason for hiding this comment

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

The button should be noop'ed when ! fontFamiliesHasChanges

>
Expand Down
Loading