Skip to content

Commit

Permalink
Fix indeterminate state and e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Apr 3, 2022
1 parent 6057b86 commit 06824cc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/block-editor/src/components/block-lock/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
import { store as blockEditorStore } from '../../store';

export default function BlockLockModal( { clientId, onClose } ) {
const [ lock, setLock ] = useState( {
edit: false,
move: false,
remove: false,
} );
const [ lock, setLock ] = useState( { move: false, remove: false } );
const { canEdit, canMove, canRemove, isReusable } = useSelect(
( select ) => {
const {
Expand Down Expand Up @@ -58,11 +54,11 @@ export default function BlockLockModal( { clientId, onClose } ) {

useEffect( () => {
setLock( {
edit: ! canEdit,
move: ! canMove,
remove: ! canRemove,
...( isReusable ? { edit: ! canEdit } : {} ),
} );
}, [ canEdit, canMove, canRemove ] );
}, [ canEdit, canMove, canRemove, isReusable ] );

const isAllChecked = Object.values( lock ).every( Boolean );

Expand Down Expand Up @@ -112,9 +108,9 @@ export default function BlockLockModal( { clientId, onClose } ) {
aria-checked={ ariaChecked }
onChange={ ( newValue ) =>
setLock( {
edit: isReusable ? newValue : undefined,
move: newValue,
remove: newValue,
...( isReusable ? { edit: newValue } : {} ),
} )
}
/>
Expand All @@ -128,7 +124,7 @@ export default function BlockLockModal( { clientId, onClose } ) {
<Icon icon={ editIcon } />
</>
}
checked={ lock.edit }
checked={ !! lock.edit }
onChange={ ( edit ) =>
setLock( ( prevLock ) => ( {
...prevLock,
Expand Down

0 comments on commit 06824cc

Please sign in to comment.