From 4e949b07338d6ba6178d030f98cdcefc8ef4e976 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Tue, 19 Aug 2025 14:39:05 +0400 Subject: [PATCH] Check if element exists --- modules/ppcp-settings/resources/js/switchSettingsUi.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-settings/resources/js/switchSettingsUi.js b/modules/ppcp-settings/resources/js/switchSettingsUi.js index 67930ac25..161f970f0 100644 --- a/modules/ppcp-settings/resources/js/switchSettingsUi.js +++ b/modules/ppcp-settings/resources/js/switchSettingsUi.js @@ -40,11 +40,13 @@ document.addEventListener( 'DOMContentLoaded', () => { document.addEventListener( 'click', ( event ) => { if ( event.target.closest( '.button.button-settings-switch-ui' ) || - event.target.closest( '.ppcp-notice-wrapper:not(.inline) a.settings-switch-ui' ) || + event.target.closest( + '.ppcp-notice-wrapper:not(.inline) a.settings-switch-ui' + ) || event.target.closest( 'a[name="settings-switch-ui"]' ) || event.target .closest( '.woocommerce-inbox-note__action-button' ) - .textContent.includes( 'Switch to New Settings' ) + ?.textContent.includes( 'Switch to New Settings' ) ) { handleClick( event ); }