Skip to content

Commit 7ba8273

Browse files
ritoban23ritoban23t-hamano
authored
Accordion Block: Hide Add button in write mode (#71941)
Unlinked contributors: StackTheCode. Co-authored-by: ritoban23 <devrito@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
1 parent 0699639 commit 7ba8273

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • packages/block-library/src/accordion

‎packages/block-library/src/accordion/edit.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
useInnerBlocksProps,
77
InspectorControls,
88
BlockControls,
9+
useBlockEditingMode,
910
store as blockEditorStore,
1011
} from '@wordpress/block-editor';
1112
import { __ } from '@wordpress/i18n';
@@ -39,6 +40,8 @@ export default function Edit( {
3940
const blockProps = useBlockProps();
4041
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
4142
const { insertBlock } = useDispatch( blockEditorStore );
43+
const blockEditingMode = useBlockEditingMode();
44+
const isContentOnlyMode = blockEditingMode === 'contentOnly';
4245

4346
const innerBlocksProps = useInnerBlocksProps( blockProps, {
4447
template: [ [ ACCORDION_BLOCK_NAME ], [ ACCORDION_BLOCK_NAME ] ],
@@ -54,7 +57,7 @@ export default function Edit( {
5457

5558
return (
5659
<>
57-
{ isSingleSelected && (
60+
{ isSingleSelected && ! isContentOnlyMode && (
5861
<BlockControls group="other">
5962
<ToolbarButton onClick={ addAccordionContentBlock }>
6063
{ __( 'Add' ) }

0 commit comments

Comments
 (0)