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 <[email protected]>
  • Loading branch information
youknowriad and tyxla authored Sep 27, 2023
1 parent e154727 commit 15130e6
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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.