mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Make sure you can't trigger lookup when a different payment gateway is selected
This commit is contained in:
parent
f86f6a3f5a
commit
861034855e
1 changed files with 7 additions and 4 deletions
|
@ -11,6 +11,7 @@ let submitButtonReference = {
|
|||
unsubscribe: null,
|
||||
};
|
||||
let isLoading = false;
|
||||
let keydownHandler = null;
|
||||
|
||||
const getEmailInput = () => {
|
||||
if ( ! emailInput ) {
|
||||
|
@ -88,8 +89,9 @@ export const setupEmailFunctionality = ( onEmailSubmit ) => {
|
|||
}
|
||||
};
|
||||
|
||||
const keydownHandler = ( event ) => {
|
||||
if ( event.key === 'Enter' ) {
|
||||
keydownHandler = ( event ) => {
|
||||
const isAxoActive = wp.data.select( STORE_NAME ).getIsAxoActive();
|
||||
if ( event.key === 'Enter' && isAxoActive ) {
|
||||
event.preventDefault();
|
||||
handleEmailSubmit();
|
||||
}
|
||||
|
@ -137,8 +139,8 @@ export const setupEmailFunctionality = ( onEmailSubmit ) => {
|
|||
|
||||
export const removeEmailFunctionality = () => {
|
||||
const input = getEmailInput();
|
||||
if ( input ) {
|
||||
input.removeEventListener( 'keydown', input.onkeydown );
|
||||
if ( input && keydownHandler ) {
|
||||
input.removeEventListener( 'keydown', keydownHandler );
|
||||
}
|
||||
|
||||
if ( submitButtonReference.root ) {
|
||||
|
@ -156,6 +158,7 @@ export const removeEmailFunctionality = () => {
|
|||
);
|
||||
}
|
||||
submitButtonReference = { container: null, root: null, unsubscribe: null };
|
||||
keydownHandler = null;
|
||||
};
|
||||
|
||||
export const isEmailFunctionalitySetup = () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue