Skip to content
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: add Link and WooPay compatibility tooltip #5515

Merged

Conversation

frosso
Copy link
Contributor

@frosso frosso commented Feb 2, 2023

Changes proposed in this Pull Request

Adding a tooltip that is displayed whenever the merchant attempts to enable both WooPay and Link at the same time.

I didn't run the changelog command because it's not needed - this is getting merged into a larger feature branch

Fixes #4720

Testing instructions

I recommend reviewing these changes with the "Hide whitespace changes" setting enabled - it'll show you that it's much fewer changes: https://github.com/Automattic/woocommerce-payments/pull/5515/files?w=1

  • Go to the settings page
  • Try to enable Link and WooPay at the same time
  • A tooltip should appear
  • Enabling/disabling them individually should not display the notice

With this changes, it's still possible that a merchant has both Link and WooPay enabled at the same time. But the number of merchants that had WooPay enabled is so small, that it doesn't matter.

2023-02-02 15 13 30


  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@frosso frosso marked this pull request as ready for review February 2, 2023 23:14
@frosso frosso self-assigned this Feb 2, 2023
@frosso frosso requested review from a team and timur27 and removed request for a team February 2, 2023 23:14
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2023

Size Change: +60 B (0%)

Total Size: 1.22 MB

Filename Size Change
release/woocommerce-payments/dist/settings.css 47.5 kB +5 B (0%)
release/woocommerce-payments/dist/settings.js 113 kB +55 B (0%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 913 B
release/woocommerce-payments/assets/css/success.css 401 B
release/woocommerce-payments/dist/blocks-checkout.css 2.18 kB
release/woocommerce-payments/dist/blocks-checkout.js 37.5 kB
release/woocommerce-payments/dist/checkout.css 2.21 kB
release/woocommerce-payments/dist/checkout.js 27.9 kB
release/woocommerce-payments/dist/index.css 36.2 kB
release/woocommerce-payments/dist/index.js 382 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 771 B
release/woocommerce-payments/dist/multi-currency-switcher-block.js 56.1 kB
release/woocommerce-payments/dist/multi-currency.css 14.7 kB
release/woocommerce-payments/dist/multi-currency.js 72.5 kB
release/woocommerce-payments/dist/order.css 248 B
release/woocommerce-payments/dist/order.js 12.4 kB
release/woocommerce-payments/dist/payment-gateways.css 1.2 kB
release/woocommerce-payments/dist/payment-gateways.js 47 kB
release/woocommerce-payments/dist/payment-request.js 11.7 kB
release/woocommerce-payments/dist/platform-checkout-express-button.js 14 kB
release/woocommerce-payments/dist/platform-checkout.css 4.02 kB
release/woocommerce-payments/dist/platform-checkout.js 75.1 kB
release/woocommerce-payments/dist/subscription-edit-page.js 392 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 7.18 kB
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 12.6 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 434 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 298 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 44.1 kB
release/woocommerce-payments/dist/tos.css 236 B
release/woocommerce-payments/dist/tos.js 15.5 kB
release/woocommerce-payments/dist/upe_checkout.css 2.21 kB
release/woocommerce-payments/dist/upe_checkout.js 33 kB
release/woocommerce-payments/dist/upe-blocks-checkout.css 2.18 kB
release/woocommerce-payments/dist/upe-blocks-checkout.js 39.1 kB
release/woocommerce-payments/includes/platform-checkout/assets/css/platform-checkout-express-button.css 247 B
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 633 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 720 B
release/woocommerce-payments/vendor/automattic/jetpack-admin-ui/src/css/jetpack-icon.css 224 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.43 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.01 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 160 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.27 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.3 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.27 kB
release/woocommerce-payments/vendor/automattic/jetpack-tracking/src/js/tracks-ajax.js 789 B
release/woocommerce-payments/vendor/automattic/jetpack-tracking/src/js/tracks-callables.js 925 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 403 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.53 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 299 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 742 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 572 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 411 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.07 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.8 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.83 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.6 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 502 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 355 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 429 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 387 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.27 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 392 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.06 kB

compressed-size-action

Comment on lines +268 to +273
<VisuallyHidden>
{ __(
'Link by Stripe cannot be enabled at checkout. Click to expand.',
'woocommerce-payments'
) }
</VisuallyHidden>
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of these visually hidden components for both WooPay and Stripe Link?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added it so that screen readers can identify what the purpose of the tooltip.
The tooltip renders a button element around the SVG icon. The SVG icon is completely removed from the screen reader's text. So, without the VisuallyHidden element, a screen reader user would only "see" a button element with no text.
Adding a VisuallyHidden element adds some text for SR users, so that they can better understand the purpose of the button element.
An alternative could also have been to add an aria-label attribute on the button element.

I noticed that this article gives a decent overview of the problem: https://www.sarasoueidan.com/blog/accessible-icon-buttons/

Comment on lines +279 to +282
label={ __(
'Link by Stripe',
'woocommerce-payments'
) }
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the label prop has been added to be more 'correct' technically when using this component from Blocks? I can see that we add it and hide it with the display: none, so I'm curious what was the reasoning behind it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it has been added so that it can be more easily targeted within the tests. I noticed that some tests used it, others didn't.

@timur27 timur27 self-requested a review February 3, 2023 09:03
Copy link
Contributor

@timur27 timur27 left a 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, Francesco! Tests good and looks great as well. Approving this PR - I've just left two questions to better understand the idea behind some changes, but they shouldn't block us.

@@ -50,11 +50,11 @@ describe( 'ExpressCheckout', () => {
const updateIsPaymentRequestEnabledHandler = jest.fn();

useGetAvailablePaymentMethodIds.mockReturnValue( [ 'link', 'card' ] );
useEnabledPaymentMethodIds.mockReturnValue( [ [ 'card', 'link' ] ] );
useEnabledPaymentMethodIds.mockReturnValue( [ [ 'card' ] ] );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to tweak the tests a bit: before, both WooPay and Link were enabled.
With these changes, this test shows only one of them enabled at the same time.

@@ -172,4 +163,35 @@ describe( 'ExpressCheckout', () => {
const linkCheckbox = container.getByLabelText( 'Link by Stripe' );
expect( linkCheckbox ).not.toBeChecked();
} );

it( 'should prevent enabling both Link and WooPay at the same time', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test for the added behavior.

@@ -142,9 +177,13 @@ const ExpressCheckout = () => {
</div>
</li>
) }
<li className="express-checkout has-icon-border">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous changes had a has-icon-border classname wrapper. But it is not needed on this component. The SVGs already have a border.

<div className="express-checkout__checkbox">
<CheckboxControl
label={ __(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a label here, just for consistency

Comment on lines +279 to +282
label={ __(
'Link by Stripe',
'woocommerce-payments'
) }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it has been added so that it can be more easily targeted within the tests. I noticed that some tests used it, others didn't.

Comment on lines +268 to +273
<VisuallyHidden>
{ __(
'Link by Stripe cannot be enabled at checkout. Click to expand.',
'woocommerce-payments'
) }
</VisuallyHidden>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added it so that screen readers can identify what the purpose of the tooltip.
The tooltip renders a button element around the SVG icon. The SVG icon is completely removed from the screen reader's text. So, without the VisuallyHidden element, a screen reader user would only "see" a button element with no text.
Adding a VisuallyHidden element adds some text for SR users, so that they can better understand the purpose of the button element.
An alternative could also have been to add an aria-label attribute on the button element.

I noticed that this article gives a decent overview of the problem: https://www.sarasoueidan.com/blog/accessible-icon-buttons/

@frosso frosso merged commit 3593c55 into poc/upe-instances-multiplied Feb 3, 2023
@frosso frosso deleted the fix/link-woopay-compatibility-tooltip branch February 3, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants