-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Grid Visualizer: Improve observation logic #68230
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +152 B (+0.01%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
Flaky tests detected in 7561ed4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12461451693
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this.
This seems to be working from well from my testing.
I also notice that it's mostly seems to be top padding and top border that cause the issues, they don't cause a resize so the resize observer isn't being triggered.
setGridInfo( getGridInfo( gridElement ) ); | ||
} ); | ||
mutationObserver.observe( gridElement, { | ||
attributeFilter: [ 'style' ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if 'class' should also be added to this list. Change block style variations or adding a custom classname could also result in a change of top padding/border.
Thanks for the PR! Sorry, I forgot to attach the video, so I uploaded it.
I think this is right, so I would like to add it. |
* Grid Visualizer: Improve observation logic * Add `class` to `attributeFilter` Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org>
@t-hamano, just letting you know #68842. I’d appreciate your 👀 on that one 🙇. |
Fix the issue found in this comment: #64425 (review)
What?
This PR makes the grid visualizer's frames match their actual child elements more accurately.
Why?
This component is used to draw the frames for the blocks inside it when the block is a grid layout type. This frame is re-rendered when the grid block or its children change size. However, when padding or borders are applied to a grid block, this frame may not match the actual child blocks:
How?
To resolve this mismatch, I made two changes:
MutationObserber
to monitor changes to style attributes, so that the frame is re-rendered when, for example, the vertical padding changes.getGridInfo()
function, include the border width for padding calculations.Testing Instructions
ResizeObserver
nor theMutationObserber
can detect the change. If you have an approach to solve this, please let me know.Screenshots or screencast
92d7b58f5c6f6f8c17476b0216dc9c86.mp4