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

Use consistent and semantically correct HTML elements in the Cart and Checkout blocks #9065

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 @@ -35,7 +35,6 @@ const OrderSummary = ( {
{ __( 'Order summary', 'woo-gutenberg-products-block' ) }
</span>
}
titleTag="h2"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue description on #8976 states the following:

The title Order summary uses a <span> element instead of an <h2> element.

Given that this element will contain a few sub elements, I believe using a <div> is the better option here. Therefore, instead of changing titleTag="h2" to titleTag="span", I removed that part, as div is defined as the default titleTag.

>
<div className="wc-block-components-order-summary__content">
{ cartItems.map( ( cartItem ) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import Title from '@woocommerce/base-components/title';
import classnames from 'classnames';

const Block = ( {
Expand All @@ -12,12 +11,11 @@ const Block = ( {
content: string;
} ): JSX.Element => {
return (
<Title
headingLevel="2"
<span
className={ classnames( className, 'wc-block-cart__totals-title' ) }
>
{ content }
</Title>
</span>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import { PlainText, useBlockProps } from '@wordpress/block-editor';
import Title from '@woocommerce/base-components/title';
import classnames from 'classnames';

/**
Expand All @@ -24,8 +23,7 @@ export const Edit = ( {
const blockProps = useBlockProps();
return (
<div { ...blockProps }>
<Title
headingLevel="2"
<span
className={ classnames(
className,
'wc-block-cart__totals-title'
Expand All @@ -39,7 +37,7 @@ export const Edit = ( {
}
style={ { backgroundColor: 'transparent' } }
/>
</Title>
</span>
</div>
);
};
Expand Down