-
Notifications
You must be signed in to change notification settings - Fork 219
Product Collection - shrink columns to fit #11320
Product Collection - shrink columns to fit #11320
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: +1.68 kB (0%) Total Size: 1.54 MB
ℹ️ View Unchanged
|
So I was able to trigger a console warning:
|
@roykho, nice catch! I can't reproduce it sthough. Am I doing something wrong? See video below: warning.movI repeated the steps also in the post and also in the scenario in which I add Product Collection on |
Interesting indeed. Please see video: file.movJust to note that I tested this with WP 6.3.2 and WP 6.4-RC.1 and with GB disabled. |
Thanks for the video, I'll be checking it further! |
checked={ !! shrinkColumns } | ||
label={ toggleLabel } | ||
help={ toggleHelp } | ||
onChange={ onToggleChange } |
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 would suggest a more descriptive naming for the "onChange" callbacks because if we ever want to add more "toggle" controls, onToggleChange
would not describe which settings it is referring to without looking into the details. Perhaps onShrinkColToggleChange
?
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.
Addressed in 99b6415 👍
For reference: the console warning issue (#11320 (comment)) was resolved in 624fdfc |
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.
LGTM Thanks for working on this.
@@ -61,7 +61,11 @@ protected function render( $attributes, $content, $block ) { | |||
$classnames = ''; | |||
if ( isset( $block->context['displayLayout'] ) && isset( $block->context['query'] ) ) { | |||
if ( isset( $block->context['displayLayout']['type'] ) && 'flex' === $block->context['displayLayout']['type'] ) { | |||
$classnames = "is-flex-container columns-{$block->context['displayLayout']['columns']}"; | |||
if ( $block->context['displayLayout']['shrinkColumns'] ) { |
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.
Hi @kmanijak - I didn't catch this earlier but this can potentially be undefined and will cause a PHP warning. So perhaps use ! empty()
check?
What
Add an option to "Shrink columns to fit" in Product Collection so the blocks is responsive.
Fixes #10827
Why
Product Collection has the option to set a number of columns but it's a fixed number which looks weird on smaller screens. That number of columns collapses to a single one on mobile devices ( check #9971).
This option allows to set a MAX number of columns but as the screen gets narrower, the number of columns decreases.
The minimal width of a product was chosen arbitrarily to
150px
and is a subject to change (I'm open to suggestion in this area).Testing Instructions
Please consider any edge cases this change may have, and also other areas of the product this may impact.
Screenshots or screencast
WooCommerce Visibility
Required:
Checklist
Required:
[type]
label or a[skip-changelog]
label.Conditional:
[skip-changelog]
label is not present).Changelog