Skip to content

Commit

Permalink
Fix reusable block locking
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Apr 28, 2022
1 parent cdaefc3 commit 7bb9963
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ import { useSelect } from '@wordpress/data';
import { store as blockEditorStore } from '../../store';

export default function useBlockOverlayActive( clientId ) {
const { isParentSelected, hasChildSelected } = useSelect(
return useSelect(
( select ) => {
const { isBlockSelected, hasSelectedInnerBlock } = select(
blockEditorStore
const {
isBlockSelected,
hasSelectedInnerBlock,
canEditBlock,
} = select( blockEditorStore );

return (
! canEditBlock( clientId ) ||
( ! isBlockSelected( clientId ) &&
! hasSelectedInnerBlock( clientId, true ) )
);
return {
isParentSelected: isBlockSelected( clientId ),
hasChildSelected: hasSelectedInnerBlock( clientId, true ),
};
},
[ clientId ]
);

return ! isParentSelected && ! hasChildSelected;
}
5 changes: 1 addition & 4 deletions packages/compose/src/hooks/use-disabled/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,9 @@ export default function useDisabled( {

/** A variable keeping track of the previous updates in order to restore them. */
/** @type {Function[]} */
let updates = [];
const updates = [];

const disable = () => {
// Restore previous updates.
updates = [];

if ( node.style.getPropertyValue( 'user-select' ) !== 'none' ) {
const previousValue = node.style.getPropertyValue(
'user-select'
Expand Down

0 comments on commit 7bb9963

Please sign in to comment.