Skip to content

Commit

Permalink
Make the Settings panel toggle button show its keyboard shortcut in i…
Browse files Browse the repository at this point in the history
…ts tooltip (WordPress#65322)

* Make the Settings panel toggle button show its keyboard shortcut in its tooltip.

* Do not pass shortcut prop to PluginSidebar and simplify.

Co-authored-by: afercia <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored Sep 19, 2024
1 parent d912271 commit 74707b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
7 changes: 1 addition & 6 deletions packages/editor/src/components/plugin-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
import { ComplementaryArea } from '@wordpress/interface';

/**
Expand Down Expand Up @@ -77,12 +76,9 @@ import { store as editorStore } from '../../store';
* ```
*/
export default function PluginSidebar( { className, ...props } ) {
const { postTitle, shortcut } = useSelect( ( select ) => {
const { postTitle } = useSelect( ( select ) => {
return {
postTitle: select( editorStore ).getEditedPostAttribute( 'title' ),
shortcut: select(
keyboardShortcutsStore
).getShortcutRepresentation( 'core/editor/toggle-sidebar' ),
};
}, [] );
return (
Expand All @@ -91,7 +87,6 @@ export default function PluginSidebar( { className, ...props } ) {
className="editor-sidebar"
smallScreenTitle={ postTitle || __( '(no title)' ) }
scope="core"
toggleShortcut={ shortcut }
{ ...props }
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function ComplementaryAreaToggle( {
icon,
selectedIcon,
name,
shortcut,
...props
} ) {
const ComponentToUse = as;
Expand All @@ -26,8 +27,10 @@ function ComplementaryAreaToggle( {
identifier,
[ identifier, scope ]
);

const { enableComplementaryArea, disableComplementaryArea } =
useDispatch( interfaceStore );

return (
<ComponentToUse
icon={ selectedIcon && isSelected ? selectedIcon : icon }
Expand All @@ -39,6 +42,7 @@ function ComplementaryAreaToggle( {
enableComplementaryArea( scope, identifier );
}
} }
shortcut={ shortcut }
{ ...props }
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ function ComplementaryArea( {
showTooltip={ ! showIconLabels }
variant={ showIconLabels ? 'tertiary' : undefined }
size="compact"
shortcut={ toggleShortcut }
/>
) }
</PinnedItems>
Expand Down

0 comments on commit 74707b6

Please sign in to comment.