From b439cc7755628f6ee2394023b39900cea7c783e9 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Thu, 6 Oct 2022 13:01:54 +0200 Subject: [PATCH] Make the tooltip always show. --- .../editor/src/components/post-saved-state/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/editor/src/components/post-saved-state/index.js b/packages/editor/src/components/post-saved-state/index.js index ceb855c582a9d3..7d57b2a630e4e0 100644 --- a/packages/editor/src/components/post-saved-state/index.js +++ b/packages/editor/src/components/post-saved-state/index.js @@ -151,7 +151,18 @@ export default function PostSavedState( { : undefined } onClick={ isDisabled ? undefined : () => savePost() } + /* + * We want the tooltip to show the keyboard shortcut only when the + * button does something, i.e. when it's not disabled. + */ shortcut={ isDisabled ? undefined : displayShortcut.primary( 's' ) } + /* + * Displaying the keyboard shortcut conditionally makes the tooltip + * itself show conditionally. This would trigger a full-rerendering + * of the button that we want to avoid. By setting `showTooltip`, + & the tooltip is always rendered even when there's no keyboard shortcut. + */ + showTooltip variant="tertiary" icon={ isLargeViewport ? undefined : cloudUpload } // Make sure the aria-label has always a value, as the default `text` is undefined on small screens.