Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

iamdharmesh
Copy link
Collaborator

All Submissions:

  • Does your code follow the WooCommerce Sniffs variant of WordPress coding standards?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Will this change require new documentation or changes to existing documentation?

Changes proposed in this Pull Request:

As reported in SQUARE-176, currently Buy with Gpay button opens new window without warning. This PR updates the aria-label attribute of the button to add a warning for "opens in a new window".

Note

The approach followed in this PR might not be the best possible one, but the button markup is rendered by the Google Pay script. So, we don’t have any other way to fix this except by handling it this way, or alternatively, we could report the issue upstream and wait for it to be fixed and released there.

Closes https://linear.app/a8c/issue/SQUARE-176/accessibility-buttonlink-opens-new-window-or-tab-without-warning

Steps to test the changes in this Pull Request:

  1. Configure Square Digital wallets.
  2. Go to any single product page
  3. Turn on the screen reader.
  4. Focus on the "Buy with Gpay" button and Verify that it announces the Buy with GPay and the warning that the link opens in a new tab
  5. Go to cart and checkout pages (Block and Classic both) and verify the same.

Changelog entry

Fix - Ensure users are warned that clicking “Buy with GPay” opens in a new window

@iamdharmesh iamdharmesh self-assigned this Sep 4, 2025
@iamdharmesh iamdharmesh requested a review from Copilot September 4, 2025 11:25
Copilot

This comment was marked as outdated.

@iamdharmesh iamdharmesh added this to the Future Release milestone Sep 4, 2025
Copilot

This comment was marked as outdated.

@iamdharmesh iamdharmesh requested a review from Copilot September 4, 2025 12:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds accessibility improvements to the Google Pay button by updating its aria-label to warn users that clicking the button opens in a new window, addressing SQUARE-176. The change ensures better screen reader support and complies with accessibility guidelines.

  • Modifies Google Pay button initialization to append accessibility warning text
  • Adds localized text strings for "Buy with GPay" and "opens in a new window"
  • Implements the fix in both JavaScript frontend code and React blocks

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/js/frontend/wc-square-digital-wallet.js Updates Google Pay button initialization to modify aria-label with accessibility warning
src/blocks/digital-wallets/hooks.js Adds similar aria-label modification for React-based Google Pay implementation
includes/Gateway/Digital_Wallet.php Provides localized text strings for the accessibility warning

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@dkotter dkotter left a comment

Choose a reason for hiding this comment

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

Overall this looks good, left a minor comment.

The approach followed in this PR might not be the best possible one, but the button markup is rendered by the Google Pay script. So, we don’t have any other way to fix this except by handling it this way, or alternatively, we could report the issue upstream and wait for it to be fixed and released there.

This would be great to fix upstream, just not sure how likely that will be or how long that will take. I think we continue with this but if it's easy enough for us to open a PR upstream, I think that would be good to do in parallel and we can always remove this code in the future if it does get fixed

@iamdharmesh
Copy link
Collaborator Author

iamdharmesh commented Sep 5, 2025

This would be great to fix upstream, just not sure how likely that will be or how long that will take. I think we continue with this but if it's easy enough for us to open a PR upstream, I think that would be good to do in parallel and we can always remove this code in the future if it does get fixed

I’m not sure where to report this issue or raise the PR. The button is rendered by this script, and I don’t think it’s a public repo (at least I couldn’t find it). I think we can report the issue on this repo: https://github.com/google-pay/google-pay-button. That may help us get it fixed in the script by the team there. 🤔

@qasumitbagthariya
Copy link
Collaborator

QA Update ✅


I have verified this PR in the fix/SQUARE-176 branch, which has been fixed and is functioning as intended.

I tested the following on this branch:

Block theme

Product page
https://github.com/user-attachments/assets/c56911ae-338a-4e5c-86a9-efbe4641854b

Cart Page
image

Checkout Page
https://github.com/user-attachments/assets/65666eec-651c-4e41-809b-75ce3852d67d

Classic

Product page

Screen.Recording.2025-09-09.at.7.05.08.PM.mov

Cart Page

Screen.Recording.2025-09-09.at.7.44.24.PM.mov

Checkout Page

Screen.Recording.2025-09-09.at.7.45.10.PM.mov

Testing Environment

  • WordPress: 6.8.2
  • Theme: Storefront 4.6.1
  • Theme: Twenty Twenty-Five 1.3
  • WooCommerce - 10.1.0
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS 15.2
  • Branch: fix/SQUARE-176

Steps to Test- As mentioned in the PR description.
Test Results - It is working as expected.
Functional Demo / Screencast -
Special Notes - Ready for UAT
Testing Document status:
Cases related to this Issue/PR are added to the Critical Flow Wiki pages:

  • Yes
  • Not Required/Applicable for this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants