Skip to content

Commit

Permalink
Pass context to in use-input
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 28, 2024
1 parent 16fc089 commit 7f8771e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { useRefEffect } from '@wordpress/compose';
import { useContext } from '@wordpress/element';
import { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';
import {
createBlock,
Expand All @@ -16,6 +17,7 @@ import {
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';
import BlockContext from '../block-context';

/**
* Handles input for selections across blocks.
Expand All @@ -42,6 +44,7 @@ export default function useInput() {
__unstableExpandSelection,
__unstableMarkAutomaticChange,
} = useDispatch( blockEditorStore );
const blockContext = useContext( BlockContext );

return useRefEffect( ( node ) => {
function onBeforeInput( event ) {
Expand Down Expand Up @@ -115,7 +118,7 @@ export default function useInput() {
getBlockRootClientId( clientId )
)
) {
__unstableSplitSelection();
__unstableSplitSelection( [], blockContext );
event.preventDefault();
}
}
Expand All @@ -131,7 +134,7 @@ export default function useInput() {
createBlock( getDefaultBlockName() )
);
} else {
__unstableSplitSelection();
__unstableSplitSelection( [], blockContext );
}
} else if (
event.keyCode === BACKSPACE ||
Expand Down

0 comments on commit 7f8771e

Please sign in to comment.