Skip to content

Commit 4f47751

Browse files
author
Kristófer Reykjalín
authored
Use the LoadingMask component from WooCommerce Blocks for PRB loading status in the Cart and Checkout Blocks (#2248)
1 parent a86630b commit 4f47751

File tree

3 files changed

+27
-40
lines changed

3 files changed

+27
-40
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Tweak - Redirect to the settings tab after an account is connected.
77
* Tweak - Prompt message when navigating out Stripe settings with unsaved changes
88
* Tweak - Show toast when payment methods list is updated with new payment methods.
9+
* Tweak - Use the newly exposed LoadableMask component provided by WooCommerce Blocks to trigger the loading state for Payment Request Buttons.
910
* Fix - JS error on checkout when Boleto method was not active.
1011
* Fix - Fixed bug that show "Use new payment method" on pay order page when there were no saved card was.
1112
* Tweak - Autocomplete for account keys and webhooks fields were disabled.

client/blocks/payment-request/payment-request-express.js

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { __ } from '@wordpress/i18n';
12
import {
23
Elements,
34
PaymentRequestButtonElement,
@@ -38,6 +39,7 @@ import { getBlocksConfiguration } from 'wcstripe/blocks/utils';
3839
*/
3940
const PaymentRequestExpressComponent = ( {
4041
billing,
42+
components,
4143
shippingData,
4244
onClick,
4345
onClose,
@@ -91,49 +93,41 @@ const PaymentRequestExpressComponent = ( {
9193
return null;
9294
}
9395

96+
const { LoadingMask } = components;
97+
9498
if ( isCustom ) {
9599
return (
96-
<div
97-
className={
98-
isUpdatingPaymentRequest
99-
? 'wc-block-components-loading-mask'
100-
: ''
101-
}
100+
<LoadingMask
101+
isLoading={ isUpdatingPaymentRequest }
102+
screenReaderLabel={ __(
103+
'Loading payment request…',
104+
'woocommerce-gateway-stripe'
105+
) }
102106
>
103107
<CustomButton
104-
className={
105-
isUpdatingPaymentRequest
106-
? 'wc-block-components-loading-mask__children'
107-
: ''
108-
}
109108
onButtonClicked={ ( evt ) => {
110109
onPaymentRequestButtonClick( evt, paymentRequest );
111110
} }
112111
/>
113-
</div>
112+
</LoadingMask>
114113
);
115114
}
116115

117116
if ( isBranded && shouldUseGooglePayBrand() ) {
118117
return (
119-
<div
120-
className={
121-
isUpdatingPaymentRequest
122-
? 'wc-block-components-loading-mask'
123-
: ''
124-
}
118+
<LoadingMask
119+
isLoading={ isUpdatingPaymentRequest }
120+
screenReaderLabel={ __(
121+
'Loading payment request…',
122+
'woocommerce-gateway-stripe'
123+
) }
125124
>
126125
<GooglePayButton
127-
className={
128-
isUpdatingPaymentRequest
129-
? 'wc-block-components-loading-mask__children'
130-
: ''
131-
}
132126
onButtonClicked={ ( evt ) => {
133127
onPaymentRequestButtonClick( evt, paymentRequest );
134128
} }
135129
/>
136-
</div>
130+
</LoadingMask>
137131
);
138132
}
139133

@@ -146,30 +140,21 @@ const PaymentRequestExpressComponent = ( {
146140
}
147141

148142
return (
149-
// The classNames here manually trigger the loading state for the PRB. Hopefully we'll
150-
// see an API introduced to WooCommerce Blocks that will let us control this without
151-
// relying on a CSS class.
152-
// - @reykjalin
153-
<div
154-
className={
155-
isUpdatingPaymentRequest
156-
? 'wc-block-components-loading-mask'
157-
: ''
158-
}
143+
<LoadingMask
144+
isLoading={ isUpdatingPaymentRequest }
145+
screenReaderLabel={ __(
146+
'Loading payment request…',
147+
'woocommerce-gateway-stripe'
148+
) }
159149
>
160150
<PaymentRequestButtonElement
161-
className={
162-
isUpdatingPaymentRequest
163-
? 'wc-block-components-loading-mask__children'
164-
: ''
165-
}
166151
onClick={ onPaymentRequestButtonClick }
167152
options={ {
168153
style: paymentRequestButtonStyle,
169154
paymentRequest,
170155
} }
171156
/>
172-
</div>
157+
</LoadingMask>
173158
);
174159
};
175160

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ If you get stuck, you can ask for help in the Plugin Forum.
131131
= 6.x.x - 2022-xx-xx =
132132
* Fix - Fixed capitalization for payment method names: iDEAL, giropay, and Sofort.
133133
* Add - Text to explain how to enable webhooks when manually entering your API keys in the new Stripe settings.
134+
* Tweak - Use the newly exposed LoadableMask component provided by WooCommerce Blocks to trigger the loading state for Payment Request Buttons.
134135
* Tweak - Redirect to the settings tab after an account is connected
135136
* Tweak - Prompt message when navigating out Stripe settings with unsaved changes
136137
* Tweak - Show toast when payment methods list is updated with new payment methods.

0 commit comments

Comments
 (0)