Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Fix JS error visible in the editor caused by Mini Cart Contents buttons #9039

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@ export const Edit = ( {
};
setAttributes: ( attributes: Record< string, unknown > ) => void;
} ): JSX.Element => {
const blockProps = useBlockProps();
const blockProps = useBlockProps( {
className: 'wc-block-mini-cart__footer-cart',
} );
const { cartButtonLabel } = attributes;

return (
<EditableButton
{ ...blockProps }
className="wc-block-mini-cart__footer-cart"
variant={ getVariant( blockProps.className, 'outlined' ) }
value={ cartButtonLabel }
placeholder={ defaultCartButtonLabel }
onChange={ ( content ) => {
setAttributes( {
cartButtonLabel: content,
} );
} }
/>
<div { ...blockProps }>
<EditableButton
variant={ getVariant( blockProps.className, 'outlined' ) }
value={ cartButtonLabel }
placeholder={ defaultCartButtonLabel }
onChange={ ( content ) => {
setAttributes( {
cartButtonLabel: content,
} );
} }
/>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,24 @@ export const Edit = ( {
};
setAttributes: ( attributes: Record< string, unknown > ) => void;
} ): JSX.Element => {
const blockProps = useBlockProps();
const blockProps = useBlockProps( {
className: classNames( 'wc-block-mini-cart__footer-checkout' ),
} );
const { checkoutButtonLabel } = attributes;

return (
<EditableButton
{ ...blockProps }
className={ classNames(
'wc-block-mini-cart__footer-checkout',
blockProps.className
) }
variant={ getVariant( blockProps.className, 'contained' ) }
value={ checkoutButtonLabel }
placeholder={ defaultCheckoutButtonLabel }
onChange={ ( content ) => {
setAttributes( {
checkoutButtonLabel: content,
} );
} }
/>
<div { ...blockProps }>
<EditableButton
variant={ getVariant( blockProps.className, 'contained' ) }
value={ checkoutButtonLabel }
placeholder={ defaultCheckoutButtonLabel }
onChange={ ( content ) => {
setAttributes( {
checkoutButtonLabel: content,
} );
} }
/>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import { getIconsFromPaymentMethods } from '@woocommerce/base-utils';
import { getSetting } from '@woocommerce/settings';
import { PaymentEventsProvider } from '@woocommerce/base-context';

/**
* Internal dependencies
*/
import './editor.scss';

const PaymentMethodIconsElement = (): JSX.Element => {
const { paymentMethods } = usePaymentMethods();
return (
Expand Down Expand Up @@ -49,7 +54,9 @@ export const Edit = (): JSX.Element => {
'woo-gutenberg-products-block'
) }
/>
<InnerBlocks template={ TEMPLATE } />
<div className="wc-block-mini-cart__footer-actions">
<InnerBlocks template={ TEMPLATE } />
</div>
<PaymentEventsProvider>
<PaymentMethodIconsElement />
</PaymentEventsProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.editor-styles-wrapper .wc-block-mini-cart__footer .block-editor-inner-blocks {
width: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ export const Edit = ( {
};
setAttributes: ( attributes: Record< string, unknown > ) => void;
} ): JSX.Element => {
const blockProps = useBlockProps();
const blockProps = useBlockProps( {
className: 'wp-block-button aligncenter',
} );
const { startShoppingButtonLabel } = attributes;

return (
<div className="wp-block-button aligncenter">
<div { ...blockProps }>
<EditableButton
{ ...blockProps }
className="wc-block-mini-cart__shopping-button"
value={ startShoppingButtonLabel }
placeholder={ defaultStartShoppingButtonLabel }
Expand Down
9 changes: 6 additions & 3 deletions assets/js/blocks/mini-cart/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,21 @@ h2.wc-block-mini-cart__title {
}
}

// First selector for the frontend, second selector for the editor.
.wc-block-mini-cart__footer-actions,
.block-editor-block-list__layout {
.wc-block-mini-cart__footer-actions > .block-editor-inner-blocks > .block-editor-block-list__layout {
display: flex;
gap: $gap;

.wc-block-components-button,
.wp-block-button {
.wp-block-button,
.wp-block-woocommerce-mini-cart-cart-button-block,
.wp-block-woocommerce-mini-cart-checkout-button-block {
flex-grow: 1;
display: inline-flex;
}

.wc-block-components-button.outlined {
.wp-block-woocommerce-mini-cart-cart-button-block {
display: none;

@media only screen and (min-width: 480px) {
Expand Down