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

Block Library: Fix React Compiler error for shortcuts #67019

Merged
merged 2 commits into from
Nov 15, 2024
Merged
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
36 changes: 25 additions & 11 deletions packages/block-library/src/block-keyboard-shortcuts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,36 @@ function BlockKeyboardShortcuts() {
},
} );
} );
}, [] );
}, [ registerShortcut ] );
Copy link
Member Author

Choose a reason for hiding this comment

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

Misc. Fixes missing dep ESLint warning.


useShortcut(
'core/block-editor/transform-heading-to-paragraph',
( event ) => handleTransformHeadingAndParagraph( event, 0 )
);

[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
//the loop is based off on a constant therefore
//the hook will execute the same way every time
//eslint-disable-next-line react-hooks/rules-of-hooks
useShortcut(
`core/block-editor/transform-paragraph-to-heading-${ level }`,
( event ) => handleTransformHeadingAndParagraph( event, level )
);
} );
useShortcut(
`core/block-editor/transform-paragraph-to-heading-1`,
( event ) => handleTransformHeadingAndParagraph( event, 1 )
);
useShortcut(
`core/block-editor/transform-paragraph-to-heading-2`,
( event ) => handleTransformHeadingAndParagraph( event, 2 )
);
useShortcut(
`core/block-editor/transform-paragraph-to-heading-3`,
( event ) => handleTransformHeadingAndParagraph( event, 3 )
);
useShortcut(
`core/block-editor/transform-paragraph-to-heading-4`,
( event ) => handleTransformHeadingAndParagraph( event, 4 )
);
useShortcut(
`core/block-editor/transform-paragraph-to-heading-5`,
( event ) => handleTransformHeadingAndParagraph( event, 5 )
);
useShortcut(
`core/block-editor/transform-paragraph-to-heading-6`,
( event ) => handleTransformHeadingAndParagraph( event, 6 )
);
Mamaduka marked this conversation as resolved.
Show resolved Hide resolved

return null;
}
Expand Down
Loading