-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
GridVisualizer: Avoid over-selecting by using a new getBlockStyles private selector #64386
GridVisualizer: Avoid over-selecting by using a new getBlockStyles private selector #64386
Conversation
Size Change: +173 B (+0.01%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
1e19e46
to
7b52f34
Compare
Flaky tests detected in 7b52f34. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10347138155
|
7b52f34
to
24aa991
Compare
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. |
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.
Testing well for me, and the code looks very tidy. Nice work!
[ gridClientId ] | ||
); | ||
const occupiedRects = useMemo( () => { | ||
const rects = []; | ||
for ( const block of gridItems ) { | ||
for ( const style of Object.values( gridItemStyles ) ) { |
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 noticed that it means occupiedRects
may no longer be in block order (as it's sourced from an object).
I think it's ok though, the only thing I can see it's used for is this code, which doesn't depend on the ordering:
const isCellOccupied = occupiedRects.some( ( rect ) =>
rect.contains( column, row )
);
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.
Yeah order isn't important.
See #63976.
Stacked onto #64321.GridPopover
was callinggetBlocks( gridClientId )
which returns a new array reference every time any inner block in the grid changes. This causes all ofGridVisualizer
to update when typing into a grid cell.We only care about when one of the attributes in
style.layout
changes, so I've fixed this by adding a new private selector that returns only thestyle
key of the given blocks.Before:
before.mp4
After:
after.mp4