Skip to content

Commit 2937d6a

Browse files
committed
Block UI during onApprove callback on classic components
1 parent 7a230ec commit 2937d6a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

modules/ppcp-button/resources/js/modules/Helper/Spinner.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class Spinner {
2020
unblock() {
2121
jQuery( this.target ).unblock();
2222
}
23-
}
2423

24+
static fullPage() {
25+
return new Spinner( window );
26+
}
27+
}
2528
export default Spinner;

modules/ppcp-button/resources/js/modules/OnApproveHandler/onApproveForContinue.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Spinner from '../Helper/Spinner';
2+
13
const initiateRedirect = ( successUrl ) => {
24
/**
35
* Notice how this step initiates a redirect to a new page using a plain
@@ -15,6 +17,10 @@ const initiateRedirect = ( successUrl ) => {
1517

1618
const onApprove = ( context, errorHandler ) => {
1719
return ( data, actions ) => {
20+
// Block the entire page during approval process
21+
const spinner = Spinner.fullPage();
22+
spinner.block();
23+
1824
const canCreateOrder =
1925
! context.config.vaultingEnabled || data.paymentSource !== 'venmo';
2026

@@ -50,6 +56,9 @@ const onApprove = ( context, errorHandler ) => {
5056

5157
const orderReceivedUrl = approveData.data?.order_received_url;
5258
initiateRedirect( orderReceivedUrl || context.config.redirect );
59+
} )
60+
.finally( () => {
61+
spinner.unblock();
5362
} );
5463
};
5564
};

0 commit comments

Comments
 (0)