Skip to content

Fix: Space visualizer showing previous value #69747

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

Merged
merged 2 commits into from
Apr 1, 2025

Conversation

karthikeya-io
Copy link
Contributor

@karthikeya-io karthikeya-io commented Mar 28, 2025

What?

Part of #63191

Why?

Fixes the issue that Margin and Padding visualizer shows the previous value. This issue doesn't occur in Safari but occurs in Chromium based browsers.

Related PR #59227

How?

Use MutationObserver to observe the changes in block.

Testing Instructions

  1. Open a post or page.
  2. Insert a block and tweak the margin or padding styles.
  3. The Space visualizer should appear accurately.

Testing Instructions for Keyboard

Same

Screenshots or screencast

Before After
space-visualizer-before.mov
space-visualizer-after.mov

Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @karthikeya-io! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Mar 28, 2025
@karthikeya-io karthikeya-io marked this pull request as ready for review March 29, 2025 08:42
Copy link

github-actions bot commented Mar 29, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: karthikeya-io <karthikeya01@git.wordpress.org>
Co-authored-by: stokesman <presstoke@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@stokesman stokesman self-requested a review March 29, 2025 17:00
@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] Block editor /packages/block-editor [Feature] Layout Layout block support, its UI controls, and style output. labels Mar 31, 2025
Copy link
Contributor

@stokesman stokesman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Thanks for working on it. I’ve experimented with some alternatives and it does seem like leveraging a MutationObserver is the best bet.

I’ve tested this and didn’t find any problems. I think it might not be necessary to observe the class attribute and just the style may suffice but I don’t think it’s likely to be critical for performance and may be helpful in some less common cases.

I’d be okay with this landing as is but I have a few suggestions.

@karthikeya-io karthikeya-io force-pushed the fix/spacing-visualizer branch from 9089c02 to a3b76b8 Compare April 1, 2025 07:09
@karthikeya-io karthikeya-io requested a review from stokesman April 1, 2025 07:16
Copy link
Contributor

@stokesman stokesman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested again and this works great. Thanks!

@stokesman stokesman merged commit efa7763 into WordPress:trunk Apr 1, 2025
62 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.7 milestone Apr 1, 2025
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
* Fix: Space visualizer showing previous value

* Refactor: replace useLayoutEffect with useEffect and remove unnecessary value from deps

Co-authored-by: karthikeya-io <karthikeya01@git.wordpress.org>
Co-authored-by: stokesman <presstoke@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Layout Layout block support, its UI controls, and style output. First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants