Skip to content

Commit

Permalink
Spacer: Ensure changes are marked as not persistent in multiple con…
Browse files Browse the repository at this point in the history
…ditions
  • Loading branch information
yogeshbhutkar committed Jan 24, 2025
1 parent 98cbba7 commit 152734a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/block-library/src/spacer/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,13 @@ const SpacerEdit = ( {
};

useEffect( () => {
// This ensures the next change is not marked as persistent
// which lets the user undo the change.
__unstableMarkNextChangeAsNotPersistent();

if (
isFlexLayout &&
selfStretch !== 'fill' &&
selfStretch !== 'fit' &&
flexSize === undefined
) {
__unstableMarkNextChangeAsNotPersistent();
if ( inheritedOrientation === 'horizontal' ) {
// If spacer is moving from a vertical container to a horizontal container,
// it might not have width but have height instead.
Expand Down Expand Up @@ -308,6 +305,7 @@ const SpacerEdit = ( {
isFlexLayout &&
( selfStretch === 'fill' || selfStretch === 'fit' )
) {
__unstableMarkNextChangeAsNotPersistent();
if ( inheritedOrientation === 'horizontal' ) {
setAttributes( {
width: undefined,
Expand All @@ -318,6 +316,7 @@ const SpacerEdit = ( {
} );
}
} else if ( ! isFlexLayout && ( selfStretch || flexSize ) ) {
__unstableMarkNextChangeAsNotPersistent();
if ( inheritedOrientation === 'horizontal' ) {
setAttributes( {
width: flexSize,
Expand Down

0 comments on commit 152734a

Please sign in to comment.