Skip to content

Commit

Permalink
Ensure ‘Proceed to Checkout’ Button Does Not Collapse Through WooPay …
Browse files Browse the repository at this point in the history
…Direct Checkout Flow (#9172)

Co-authored-by: Kristófer Reykjalín <13835680+reykjalin@users.noreply.github.com>
  • Loading branch information
lovo-h and reykjalin authored Jul 26, 2024
1 parent 2ad61ed commit 55a3638
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Ensure the 'Proceed to Checkout' button does not collapse when adding a loading spinner, in the Direct Checkout flow.
17 changes: 12 additions & 5 deletions client/checkout/woopay/direct-checkout/woopay-direct-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,20 +302,27 @@ class WooPayDirectCheckout {
* @param {Element} element The element to add the loading spinner to.
*/
const addLoadingSpinner = ( element ) => {
const elementCss = window.getComputedStyle( element, null );
const originalColor = elementCss.getPropertyValue( 'color' );

// Create a spinner to show when the user clicks the button.
const spinner = document.createElement( 'span' );
spinner.classList.add( 'wc-block-components-spinner' );
spinner.style.position = 'relative';
spinner.style.position = 'absolute';
spinner.style.top = '0';
spinner.style.left = '0';
spinner.style.width = '100%';
spinner.style.height = '100%';
spinner.style.color = originalColor;
spinner.style.fontSize = 'unset';
spinner.style.display = 'inline';
spinner.style.lineHeight = '0';
spinner.style.margin = '0';
spinner.style.border = '0';
spinner.style.padding = '0';
// Remove the existing content of the button.
// Set innerHTML to '&nbsp;' to keep the button's height.
element.innerHTML = '&nbsp;';
element.classList.remove( 'wc-forward' );
// Hide the existing content of the button.
element.style.color = 'rgba( 0, 0, 0, 0 )';
element.style.position = 'relative';
// Add the spinner to the button.
element.appendChild( spinner );
};
Expand Down

0 comments on commit 55a3638

Please sign in to comment.