Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spacer block, when used as Grow(Fill) or Fit, will prompt a user about unsaved changes when navigating away, even when no unsaved changes #67041

Open
4 of 6 tasks
MadtownLems opened this issue Nov 15, 2024 · 3 comments · May be fixed by #67045
Assignees
Labels
[Block] Spacer Affects the Spacer Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@MadtownLems
Copy link

Description

When you leave the Post Editor of content that contains a Spacer Block set to either Grow (previously Fill) or Fit, the browser will warn you about losing unsaved changes, even if you haven't changed anything. The issue does not impact Spacer Blocks that have a Fixed height.

Step-by-step reproduction instructions

  1. Create a new Post.
  2. Insert a Stack.
  3. Insert a Spacer within the Stack.
  4. Set it to Grow.
  5. Publish.
  6. Go back to your All Posts list.
  7. Return to editing the Post.
  8. Make no changes, but navigate away.
  9. See that you were warned about unsaved changes (even though you didn't make any)

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 6.6.2 and WordPress 6.7. Theme: Twenty Twenty Four (and others). No Gutenberg plugin.

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@MadtownLems MadtownLems added the [Type] Bug An existing feature does not function as intended label Nov 15, 2024
@Mamaduka Mamaduka added the [Block] Spacer Affects the Spacer Block label Nov 15, 2024
@Mayank-Tripathi32
Copy link

Hello,

Thank you for reporting this bug.

I have verified that the issue occurs with grow and fit, but it works fine with fixed width. I’ll now investigate possible solutions.

Thanks!

@Mayank-Tripathi32
Copy link

I’ve identified the problem—it originates from the useEffect running on load and updating attributes:

if (  isFlexLayout && ( selfStretch === 'fill' || selfStretch === 'fit' )) {

	if ( inheritedOrientation === 'horizontal' ) {
		setAttributes( {
			width: undefined,
		} );
	}  else {
		setAttributes( {
			height: undefined,
	    } );
	}
}

I’ll investigate further to determine whether this can be removed or if additional checks are needed.

@Mayank-Tripathi32
Copy link

Mayank-Tripathi32 commented Nov 15, 2024

I’ve identified the problem—it originates from the useEffect running on load and updating attributes:

if ( isFlexLayout && ( selfStretch === 'fill' || selfStretch === 'fit' )) {

if ( inheritedOrientation === 'horizontal' ) {
setAttributes( {
width: undefined,
} );
} else {
setAttributes( {
height: undefined,
} );
}
}
I’ll investigate further to determine whether this can be removed or if additional checks are needed.

I believe adding a check && width !== undefined resolves the issue. I’ll proceed with opening a PR to address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Spacer Affects the Spacer Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
3 participants