Merge pull request #3180 from woocommerce/PCP-4280-uncaught-type-error-cannot-read-properties-of-null-reading-checked

Uncaught type error cannot read properties of null reading checked (4280)
This commit is contained in:
Emili Castells 2025-03-06 09:50:08 +01:00 committed by GitHub
commit eb576afc5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View file

@ -326,9 +326,9 @@ window.ppcp_onboarding_productionCallback = function ( ...args ) {
isDisconnecting = true;
const saveButton = document.querySelector( '.woocommerce-save-button' );
saveButton.removeAttribute( 'disabled' );
saveButton.click();
const saveButton = document.querySelector( '.woocommerce-save-button' );
saveButton.removeAttribute( 'disabled' );
saveButton.click();
};
// Prevent the message about unsaved checkbox/radiobutton when reloading the page.
@ -345,9 +345,11 @@ window.ppcp_onboarding_productionCallback = function ( ...args ) {
const sandboxSwitchElement = document.querySelector( '#ppcp-sandbox_on' );
sandboxSwitchElement?.addEventListener( 'click', () => {
document.querySelector( '.woocommerce-save-button' )?.removeAttribute( 'disabled' );
});
sandboxSwitchElement?.addEventListener( 'click', () => {
document
.querySelector( '.woocommerce-save-button' )
?.removeAttribute( 'disabled' );
} );
const validate = () => {
const selectors = sandboxSwitchElement.checked
@ -389,7 +391,8 @@ window.ppcp_onboarding_productionCallback = function ( ...args ) {
const isSandboxInBackend =
PayPalCommerceGatewayOnboarding.current_env === 'sandbox';
if ( sandboxSwitchElement.checked !== isSandboxInBackend ) {
if ( sandboxSwitchElement?.checked !== isSandboxInBackend ) {
sandboxSwitchElement.checked = isSandboxInBackend;
}

View file

@ -44,6 +44,7 @@ const defaultPersistent = Object.freeze( {
threeDSecure: 'no-3d-secure',
fastlaneCardholderName: false,
fastlaneDisplayWatermark: false,
__meta: false,
} );
// Reducer logic.