Skip to content

Commit 18a6dd5

Browse files
nani-samireddynani-samireddyt-hamano
authored
Comments Pagination Block: Refactor settings panel to use ToolsPanel (#70245)
* Refactor Settings panel of Comments Pagination block to use ToolsPanel instead of PanelBody * fix: update the dropdown label for comments pagination block settings * chore: add dropdownMenuProps in comments pagination toolspanel Co-authored-by: nani-samireddy <nanisamireddy@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
1 parent a3b72ee commit 18a6dd5

File tree

1 file changed

+29
-9
lines changed
  • packages/block-library/src/comments-pagination

1 file changed

+29
-9
lines changed

packages/block-library/src/comments-pagination/edit.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ import {
1010
Warning,
1111
} from '@wordpress/block-editor';
1212
import { useSelect } from '@wordpress/data';
13-
import { PanelBody } from '@wordpress/components';
13+
import {
14+
__experimentalToolsPanel as ToolsPanel,
15+
__experimentalToolsPanelItem as ToolsPanelItem,
16+
} from '@wordpress/components';
1417

1518
/**
1619
* Internal dependencies
1720
*/
1821
import { CommentsPaginationArrowControls } from './comments-pagination-arrow-controls';
22+
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
1923

2024
const TEMPLATE = [
2125
[ 'core/comments-pagination-previous' ],
@@ -45,6 +49,7 @@ export default function QueryPaginationEdit( {
4549
}, [] );
4650

4751
const blockProps = useBlockProps();
52+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
4853
const innerBlocksProps = useInnerBlocksProps( blockProps, {
4954
template: TEMPLATE,
5055
} );
@@ -73,14 +78,29 @@ export default function QueryPaginationEdit( {
7378
<>
7479
{ hasNextPreviousBlocks && (
7580
<InspectorControls>
76-
<PanelBody title={ __( 'Settings' ) }>
77-
<CommentsPaginationArrowControls
78-
value={ paginationArrow }
79-
onChange={ ( value ) => {
80-
setAttributes( { paginationArrow: value } );
81-
} }
82-
/>
83-
</PanelBody>
81+
<ToolsPanel
82+
label={ __( 'Settings' ) }
83+
dropdownMenuProps={ dropdownMenuProps }
84+
resetAll={ () =>
85+
setAttributes( { paginationArrow: 'none' } )
86+
}
87+
>
88+
<ToolsPanelItem
89+
label={ __( 'Arrow' ) }
90+
hasValue={ () => paginationArrow !== 'none' }
91+
onDeselect={ () =>
92+
setAttributes( { paginationArrow: 'none' } )
93+
}
94+
isShownByDefault
95+
>
96+
<CommentsPaginationArrowControls
97+
value={ paginationArrow }
98+
onChange={ ( value ) => {
99+
setAttributes( { paginationArrow: value } );
100+
} }
101+
/>
102+
</ToolsPanelItem>
103+
</ToolsPanel>
84104
</InspectorControls>
85105
) }
86106
<div { ...innerBlocksProps } />

0 commit comments

Comments
 (0)