[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
This commit is contained in:
parent
af9ca20af5
commit
57ef5a884e
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import type { ReactElement } from 'react';
|
import type { ReactElement } from 'react';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
import { Main } from '@woocommerce/base-components/sidebar-layout';
|
import { Main } from '@woocommerce/base-components/sidebar-layout';
|
||||||
import { useStoreEvents } from '@woocommerce/base-context/hooks';
|
import { useStoreEvents } from '@woocommerce/base-context/hooks';
|
||||||
import { useEffect } from '@wordpress/element';
|
import { useEffect } from '@wordpress/element';
|
||||||
|
@ -27,6 +28,7 @@ const FrontendBlock = ( {
|
||||||
return (
|
return (
|
||||||
<Main className={ clsx( 'wc-block-checkout__main', className ) }>
|
<Main className={ clsx( 'wc-block-checkout__main', className ) }>
|
||||||
<form
|
<form
|
||||||
|
aria-label={ __( 'Checkout', 'woocommerce' ) }
|
||||||
className={ clsx(
|
className={ clsx(
|
||||||
'wc-block-components-form wc-block-checkout__form',
|
'wc-block-components-form wc-block-checkout__form',
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,6 @@ interface StepHeadingProps {
|
||||||
const StepHeading = ( { title, stepHeadingContent }: StepHeadingProps ) => (
|
const StepHeading = ( { title, stepHeadingContent }: StepHeadingProps ) => (
|
||||||
<div className="wc-block-components-checkout-step__heading">
|
<div className="wc-block-components-checkout-step__heading">
|
||||||
<Title
|
<Title
|
||||||
aria-hidden="true"
|
|
||||||
className="wc-block-components-checkout-step__title"
|
className="wc-block-components-checkout-step__title"
|
||||||
headingLevel="2"
|
headingLevel="2"
|
||||||
>
|
>
|
||||||
|
|
|
@ -14,7 +14,6 @@ exports[`FormStep fieldset legend should default to legend prop when title and l
|
||||||
className="wc-block-components-checkout-step__heading"
|
className="wc-block-components-checkout-step__heading"
|
||||||
>
|
>
|
||||||
<h2
|
<h2
|
||||||
aria-hidden="true"
|
|
||||||
className="wc-block-components-title wc-block-components-checkout-step__title"
|
className="wc-block-components-title wc-block-components-checkout-step__title"
|
||||||
>
|
>
|
||||||
Lorem Ipsum
|
Lorem Ipsum
|
||||||
|
@ -64,7 +63,6 @@ exports[`FormStep should remove step number CSS class if prop is false 1`] = `
|
||||||
className="wc-block-components-checkout-step__heading"
|
className="wc-block-components-checkout-step__heading"
|
||||||
>
|
>
|
||||||
<h2
|
<h2
|
||||||
aria-hidden="true"
|
|
||||||
className="wc-block-components-title wc-block-components-checkout-step__title"
|
className="wc-block-components-title wc-block-components-checkout-step__title"
|
||||||
>
|
>
|
||||||
Lorem Ipsum
|
Lorem Ipsum
|
||||||
|
@ -135,7 +133,6 @@ exports[`FormStep should render a fieldset with heading if a title is provided 1
|
||||||
className="wc-block-components-checkout-step__heading"
|
className="wc-block-components-checkout-step__heading"
|
||||||
>
|
>
|
||||||
<h2
|
<h2
|
||||||
aria-hidden="true"
|
|
||||||
className="wc-block-components-title wc-block-components-checkout-step__title"
|
className="wc-block-components-title wc-block-components-checkout-step__title"
|
||||||
>
|
>
|
||||||
Lorem Ipsum
|
Lorem Ipsum
|
||||||
|
@ -167,7 +164,6 @@ exports[`FormStep should render step description 1`] = `
|
||||||
className="wc-block-components-checkout-step__heading"
|
className="wc-block-components-checkout-step__heading"
|
||||||
>
|
>
|
||||||
<h2
|
<h2
|
||||||
aria-hidden="true"
|
|
||||||
className="wc-block-components-title wc-block-components-checkout-step__title"
|
className="wc-block-components-title wc-block-components-checkout-step__title"
|
||||||
>
|
>
|
||||||
Lorem Ipsum
|
Lorem Ipsum
|
||||||
|
@ -204,7 +200,6 @@ exports[`FormStep should render step heading content 1`] = `
|
||||||
className="wc-block-components-checkout-step__heading"
|
className="wc-block-components-checkout-step__heading"
|
||||||
>
|
>
|
||||||
<h2
|
<h2
|
||||||
aria-hidden="true"
|
|
||||||
className="wc-block-components-title wc-block-components-checkout-step__title"
|
className="wc-block-components-title wc-block-components-checkout-step__title"
|
||||||
>
|
>
|
||||||
Lorem Ipsum
|
Lorem Ipsum
|
||||||
|
@ -243,7 +238,6 @@ exports[`FormStep should set disabled prop to the fieldset element when disabled
|
||||||
className="wc-block-components-checkout-step__heading"
|
className="wc-block-components-checkout-step__heading"
|
||||||
>
|
>
|
||||||
<h2
|
<h2
|
||||||
aria-hidden="true"
|
|
||||||
className="wc-block-components-title wc-block-components-checkout-step__title"
|
className="wc-block-components-title wc-block-components-checkout-step__title"
|
||||||
>
|
>
|
||||||
Lorem Ipsum
|
Lorem Ipsum
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Improve checkout page accessibility after removing heading level 1.
|
|
@ -12,7 +12,7 @@
|
||||||
*
|
*
|
||||||
* @see https://woocommerce.com/document/template-structure/
|
* @see https://woocommerce.com/document/template-structure/
|
||||||
* @package WooCommerce\Templates
|
* @package WooCommerce\Templates
|
||||||
* @version 3.5.0
|
* @version 9.4.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
@ -29,7 +29,7 @@ if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_requir
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
|
<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' ); ?>">
|
||||||
|
|
||||||
<?php if ( $checkout->get_checkout_fields() ) : ?>
|
<?php if ( $checkout->get_checkout_fields() ) : ?>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue