From 8d6b8c5c05a2427af04e8639341ddcfac299751e Mon Sep 17 00:00:00 2001 From: Sukhendu Sekhar Guria Date: Fri, 13 Dec 2024 04:09:55 +0530 Subject: [PATCH] Refactor "Settings" panel of Table block to use ToolsPanel instead of PanelBody (#67896) Co-authored-by: Sukhendu2002 Co-authored-by: fabiankaegy --- packages/block-library/src/table/edit.js | 74 +++++++++++++++++------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/packages/block-library/src/table/edit.js b/packages/block-library/src/table/edit.js index f1cb3fa5d8b8ae..1d61bab0787e44 100644 --- a/packages/block-library/src/table/edit.js +++ b/packages/block-library/src/table/edit.js @@ -20,12 +20,13 @@ import { import { __ } from '@wordpress/i18n'; import { Button, - PanelBody, Placeholder, TextControl, ToggleControl, ToolbarDropdownMenu, __experimentalHasSplitBorders as hasSplitBorders, + __experimentalToolsPanel as ToolsPanel, + __experimentalToolsPanelItem as ToolsPanelItem, } from '@wordpress/components'; import { alignLeft, @@ -473,33 +474,66 @@ function TableEdit( { ) } - { + setAttributes( { + hasFixedLayout: true, + head: [], + foot: [], + } ); + } } > - hasFixedLayout !== true } label={ __( 'Fixed width table cells' ) } - checked={ !! hasFixedLayout } - onChange={ onChangeFixedLayout } - /> + onDeselect={ () => + setAttributes( { hasFixedLayout: true } ) + } + isShownByDefault + > + + { ! isEmpty && ( <> - head && head.length } label={ __( 'Header section' ) } - checked={ !! ( head && head.length ) } - onChange={ onToggleHeaderSection } - /> - + setAttributes( { head: [] } ) + } + isShownByDefault + > + + + foot && foot.length } label={ __( 'Footer section' ) } - checked={ !! ( foot && foot.length ) } - onChange={ onToggleFooterSection } - /> + onDeselect={ () => + setAttributes( { foot: [] } ) + } + isShownByDefault + > + + ) } - + { ! isEmpty && (