-
Notifications
You must be signed in to change notification settings - Fork 219
Fix: Mini Cart template part editor height #5825
Conversation
Size Change: +2.26 kB (0%) Total Size: 816 kB
ℹ️ View Unchanged
|
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.
The fix works great 🎉 but it would be great if we could keep it in scss along other overrides.
const blockProps = useBlockProps( { | ||
style: { | ||
minHeight: '100vh', | ||
}, | ||
} ); |
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.
Can we move it to css at https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/d67e5191f0265a9ea8eb02aa274b9d3f459335ff/assets/js/blocks/cart-checkout/mini-cart-contents/editor.scss#L1-L6
We already have the max-width
styles and other editor specific styles living there.
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.
@tomasztunik Hey there 👋🏽 , #5813 is caused by a race condition related to loading CSS files. When we switch to edit the Mini Cart template part, the Site Editor calculates the height of the editor based on the height of template content, the editor style of the Mini Cart Contents block hasn't been loaded yet, which causes the issue we're fixing in this PR. I have to use the inline style to avoid the race condition so the Site Editor can calculate the correct height every time the template part is loaded.
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.
On trunk
, if you switch back and forth editing the template part, the editor height is correct the second time.
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.
Ah, I see. I didn't understand the full context properly. Would it be worth to document it with a comment so whoever stumbles upon it doesn't move it to styles in the future?
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.
Would it be worth to document it with a comment so whoever stumbles upon it doesn't move it to styles in the future?
@tomasztunik I added the comment explaining the usage of the inline 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.
thanks!
Fixes #5813
When a template part is loaded, Gutenberg set the height of the editor area using
iframe.contentDocument.documentElement.scrollHeight
, at this point, the editor CSS hasn't been loaded yet, which causes the issue in #5813. If we switch to edit another template, then switch back to edit the Mini Cart template part, the height is correct because, at that point, the CSS had been loaded.This PR uses the inline style to set the height of the Mini Cart Contents block so Gutenberg can calculate the correct height when loading the template part.
Screenshots
Testing
Automated Tests
Manual Testing
How to test the changes in this Pull Request:
User Facing Testing
These are steps for user testing (where "user" is someone interacting with this change that is not editing any code).