Skip to content

Commit

Permalink
Don't render toolbar icon if user can't interact
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Mar 21, 2022
1 parent bfef6de commit dcd311a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
4 changes: 0 additions & 4 deletions packages/block-editor/src/components/block-lock/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,4 @@
right: $grid-unit-15 !important;
}
}

.components-button[aria-disabled="true"] {
opacity: 1;
}
}
29 changes: 12 additions & 17 deletions packages/block-editor/src/components/block-lock/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,30 @@ export default function BlockLockToolbar( { clientId } ) {
false
);

if ( canMove && canRemove ) {
if ( ! canLockBlocks ) {
return null;
}

const label = canLockBlocks
? sprintf(
/* translators: %s: block name */
__( 'Unlock %s' ),
blockInformation.title
)
: sprintf(
/* translators: %s: block name */
__( 'Locked %s' ),
blockInformation.title
);
if ( canMove && canRemove ) {
return null;
}

return (
<>
<ToolbarGroup className="block-editor-block-lock-toolbar">
<ToolbarButton
icon={ lock }
label={ label }
onClick={ canLockBlocks ? toggleModal : undefined }
aria-disabled={ ! canLockBlocks }
label={ sprintf(
/* translators: %s: block name */
__( 'Unlock %s' ),
blockInformation.title
) }
onClick={ toggleModal }
/>
</ToolbarGroup>
{ isModalOpen && canLockBlocks ? (
{ isModalOpen && (
<BlockLockModal clientId={ clientId } onClose={ toggleModal } />
) : null }
) }
</>
);
}

0 comments on commit dcd311a

Please sign in to comment.