Skip to content

Commit

Permalink
Fix the ShortcutProvider usage (#54851)
Browse files Browse the repository at this point in the history
Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
  • Loading branch information
youknowriad and tyxla committed Sep 27, 2023
1 parent e154727 commit 15130e6
Showing 1 changed file with 3 additions and 3 deletions.
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { useRef } from '@wordpress/element';
import { useState } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -20,12 +20,12 @@ const { Provider } = context;
* @return {import('@wordpress/element').WPElement} Component.
*/
export function ShortcutProvider( props ) {
const keyboardShortcuts = useRef( new Set() );
const [ keyboardShortcuts ] = useState( () => new Set() );

function onKeyDown( event ) {
if ( props.onKeyDown ) props.onKeyDown( event );

for ( const keyboardShortcut of keyboardShortcuts.current ) {
for ( const keyboardShortcut of keyboardShortcuts ) {
keyboardShortcut( event );
}
}
Expand Down

0 comments on commit 15130e6

Please sign in to comment.