Fix Featured Product block frontend mismatch (https://github.com/woocommerce/woocommerce-blocks/pull/6263)
If the Featured Product block was added but not modified at all, the block would not match the editor on the front end. This was due to the fact that, on the frontend, the block is SSR and was missing some defaults which were present in JS.
This commit is contained in:
parent
54fba3fe4e
commit
9b6d0e0e0f
|
@ -25,9 +25,10 @@ class FeaturedProduct extends AbstractDynamicBlock {
|
|||
'dimRatio' => 50,
|
||||
'focalPoint' => false,
|
||||
'imageFit' => 'none',
|
||||
'minHeight' => false,
|
||||
'minHeight' => 500,
|
||||
'mediaId' => 0,
|
||||
'mediaSrc' => '',
|
||||
'overlayColor' => '#000000',
|
||||
'showDesc' => true,
|
||||
'showPrice' => true,
|
||||
);
|
||||
|
@ -185,8 +186,10 @@ class FeaturedProduct extends AbstractDynamicBlock {
|
|||
public function get_styles( $attributes ) {
|
||||
$style = '';
|
||||
|
||||
$min_height = isset( $attributes['minHeight'] ) ? $attributes['minHeight'] : wc_get_theme_support( 'featured_block::default_height', 500 );
|
||||
|
||||
if ( isset( $attributes['minHeight'] ) ) {
|
||||
$style .= sprintf( 'min-height:%dpx;', intval( $attributes['minHeight'] ) );
|
||||
$style .= sprintf( 'min-height:%dpx;', intval( $min_height ) );
|
||||
}
|
||||
|
||||
$global_style_style = StyleAttributesUtils::get_styles_by_attributes( $attributes, $this->global_style_wrapper );
|
||||
|
|
Loading…
Reference in New Issue