Skip to content

Commit

Permalink
Query Pagination: Fix 'undo' trap (WordPress#68022)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent 5c8cda1 commit 2ee383c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/block-library/src/query-pagination/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useInnerBlocksProps,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
import { useDispatch, useSelect } from '@wordpress/data';
import {
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
Expand Down Expand Up @@ -50,17 +50,27 @@ export default function QueryPaginationEdit( {
},
[ clientId ]
);
const { __unstableMarkNextChangeAsNotPersistent } =
useDispatch( blockEditorStore );
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const blockProps = useBlockProps();
const innerBlocksProps = useInnerBlocksProps( blockProps, {
template: TEMPLATE,
} );

// Always show label text if paginationArrow is set to 'none'.
useEffect( () => {
if ( paginationArrow === 'none' && ! showLabel ) {
__unstableMarkNextChangeAsNotPersistent();
setAttributes( { showLabel: true } );
}
}, [ paginationArrow, setAttributes, showLabel ] );
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
}, [
paginationArrow,
setAttributes,
showLabel,
__unstableMarkNextChangeAsNotPersistent,
] );

return (
<>
{ hasNextPreviousBlocks && (
Expand Down

0 comments on commit 2ee383c

Please sign in to comment.