Skip to content

Commit 57ef5a8

Browse files
authored
[Accessibility] Improve Checkout block page accessibility after removing heading level 1 (#50925)
* Add aria-label to checkout form landmark * Remove aria-hidden from checkout form sub-titles * Add aria-label to checkout form * Add changelog file * Remove aria-hidden from form-step snapshots * Bump form-checkout template version
1 parent af9ca20 commit 57ef5a8

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

plugins/woocommerce-blocks/assets/js/blocks/checkout/inner-blocks/checkout-fields-block/frontend.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import type { ReactElement } from 'react';
55
import clsx from 'clsx';
6+
import { __ } from '@wordpress/i18n';
67
import { Main } from '@woocommerce/base-components/sidebar-layout';
78
import { useStoreEvents } from '@woocommerce/base-context/hooks';
89
import { useEffect } from '@wordpress/element';
@@ -27,6 +28,7 @@ const FrontendBlock = ( {
2728
return (
2829
<Main className={ clsx( 'wc-block-checkout__main', className ) }>
2930
<form
31+
aria-label={ __( 'Checkout', 'woocommerce' ) }
3032
className={ clsx(
3133
'wc-block-components-form wc-block-checkout__form',
3234
{

plugins/woocommerce-blocks/packages/components/form-step/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ interface StepHeadingProps {
1717
const StepHeading = ( { title, stepHeadingContent }: StepHeadingProps ) => (
1818
<div className="wc-block-components-checkout-step__heading">
1919
<Title
20-
aria-hidden="true"
2120
className="wc-block-components-checkout-step__title"
2221
headingLevel="2"
2322
>

plugins/woocommerce-blocks/packages/components/form-step/test/__snapshots__/index.js.snap

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ exports[`FormStep fieldset legend should default to legend prop when title and l
1414
className="wc-block-components-checkout-step__heading"
1515
>
1616
<h2
17-
aria-hidden="true"
1817
className="wc-block-components-title wc-block-components-checkout-step__title"
1918
>
2019
Lorem Ipsum
@@ -64,7 +63,6 @@ exports[`FormStep should remove step number CSS class if prop is false 1`] = `
6463
className="wc-block-components-checkout-step__heading"
6564
>
6665
<h2
67-
aria-hidden="true"
6866
className="wc-block-components-title wc-block-components-checkout-step__title"
6967
>
7068
Lorem Ipsum
@@ -135,7 +133,6 @@ exports[`FormStep should render a fieldset with heading if a title is provided 1
135133
className="wc-block-components-checkout-step__heading"
136134
>
137135
<h2
138-
aria-hidden="true"
139136
className="wc-block-components-title wc-block-components-checkout-step__title"
140137
>
141138
Lorem Ipsum
@@ -167,7 +164,6 @@ exports[`FormStep should render step description 1`] = `
167164
className="wc-block-components-checkout-step__heading"
168165
>
169166
<h2
170-
aria-hidden="true"
171167
className="wc-block-components-title wc-block-components-checkout-step__title"
172168
>
173169
Lorem Ipsum
@@ -204,7 +200,6 @@ exports[`FormStep should render step heading content 1`] = `
204200
className="wc-block-components-checkout-step__heading"
205201
>
206202
<h2
207-
aria-hidden="true"
208203
className="wc-block-components-title wc-block-components-checkout-step__title"
209204
>
210205
Lorem Ipsum
@@ -243,7 +238,6 @@ exports[`FormStep should set disabled prop to the fieldset element when disabled
243238
className="wc-block-components-checkout-step__heading"
244239
>
245240
<h2
246-
aria-hidden="true"
247241
className="wc-block-components-title wc-block-components-checkout-step__title"
248242
>
249243
Lorem Ipsum
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Improve checkout page accessibility after removing heading level 1.

plugins/woocommerce/templates/checkout/form-checkout.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* @see https://woocommerce.com/document/template-structure/
1414
* @package WooCommerce\Templates
15-
* @version 3.5.0
15+
* @version 9.4.0
1616
*/
1717

1818
if ( ! defined( 'ABSPATH' ) ) {
@@ -29,7 +29,7 @@
2929

3030
?>
3131

32-
<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
32+
<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data" aria-label="<?php echo esc_attr__( 'Checkout', 'woocommerce' ); ?>">
3333

3434
<?php if ( $checkout->get_checkout_fields() ) : ?>
3535

0 commit comments

Comments
 (0)