-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a11y issues in Cart/Checkout #47470
Conversation
Hi @nielslange, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, @senadir. I left a question regarding overwriting the Gutenberg custom hook.
Regarding the testing instructions (see note in this comment), I wonder if we should slightly improve them:
-
Notice Color:
- Currently, it states that "a notice will show a button to go to cart.". However, we are using the CSS classes
button wc-forward wp-element-button
on a link element (<a href="...">
), not a button (<button>
). We could adjust the instructions to either "a notice will show a link to go to cart" or "a notice will show a button that says 'View cart'" to avoid ambiguity.
- Currently, it states that "a notice will show a button to go to cart.". However, we are using the CSS classes
-
Return Focus on the Shipping Calculator:
- The instructions mention clicking "Change address", but this requires enabling the option "Enable the shipping calculator on the cart page" in
/wp-admin/admin.php?page=wc-settings&tab=shipping§ion=options
. The high-quality testing instructions guide suggests mentioning preconditions, actions, and validation steps. Including this setup step will help prevent confusion about making the "Change address" link visible.
- The instructions mention clicking "Change address", but this requires enabling the option "Enable the shipping calculator on the cart page" in
-
Return Focus on the Shipping Calculator and Return focus on Mini Cart:
- The instructions for return focus on the shipping calculator and the mini cart do not mention using a keyboard. However, the related issues Accessibility: Mini Cart does not return keyboard focus to the button that triggers it when closed. #43561 and Accessibility: Keyboard focus not appropriately managed on the cart page after updating address for shipping rates #43621 explicitly mention keyboard inputs. Should we include keyboard usage in the testing steps?
I updated the steps thank you @nielslange |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the testing instructions and clarifying my concern around overwriting Gutenberg's custom hook. Let's ⛴️ this improvement, @senadir. 🙌
I choose to go with a single PR instead of spamming multiple small PRs that take more time and effort to get setup than to actually fix the code.
This PR fixes the color contrast for the add to cart notice button, the cart/checkout labels, returns focus for the cart shipping calculator, button, and returns focus on whatever element opened the mini cart drawer.
The last one was tricky because we have the logic to return, it just never triggers because we don't unmount our drawer, we just hide it. Switching to removing the element from the page was too much a lift, so I customized the
useFocusReturn
hook to our usage.I reused that one for the shipping calculator as well, because Gutenberg one didn't work as well.
Closes #43619
Closes #43615
Closes #43561
Closes #43621
How to test the changes in this Pull Request:
Notice color
Cart/Checkout labels
Return focus on Shipping Calculator
Return focus on Mini Cart
Changelog entry
Significance
Type
Message
Update color contrast for Checkout fields.
Update color contrast for notice buttons.
Return focus when closing mini cart drawer.
Return focus when closing shipping calculator.
Comment