diff --git a/plugins/woocommerce-admin/client/launch-your-store/settings/slotfill.js b/plugins/woocommerce-admin/client/launch-your-store/settings/slotfill.js index 75322966ba9..a1a3ebfa624 100644 --- a/plugins/woocommerce-admin/client/launch-your-store/settings/slotfill.js +++ b/plugins/woocommerce-admin/client/launch-your-store/settings/slotfill.js @@ -11,6 +11,7 @@ import { useState, createInterpolateElement, createElement, + useEffect, } from '@wordpress/element'; import { registerPlugin } from '@wordpress/plugins'; import { __ } from '@wordpress/i18n'; @@ -32,23 +33,38 @@ import { const { Fill } = createSlotFill( SETTINGS_SLOT_FILL_CONSTANT ); const SiteVisibility = () => { - const shareKey = - window?.wcSettings?.admin?.siteVisibilitySettings - ?.woocommerce_share_key; + const setting = window?.wcSettings?.admin?.siteVisibilitySettings || {}; + const shareKey = setting?.woocommerce_share_key; const [ comingSoon, setComingSoon ] = useState( - window?.wcSettings?.admin?.siteVisibilitySettings - ?.woocommerce_coming_soon || 'no' + setting?.woocommerce_coming_soon || 'no' ); const [ storePagesOnly, setStorePagesOnly ] = useState( - window?.wcSettings?.admin?.siteVisibilitySettings - ?.woocommerce_store_pages_only + setting?.woocommerce_store_pages_only || 'no' ); const [ privateLink, setPrivateLink ] = useState( - window?.wcSettings?.admin?.siteVisibilitySettings - ?.woocommerce_private_link + setting?.woocommerce_private_link || 'no' ); + useEffect( () => { + const initValues = { + comingSoon: setting.woocommerce_coming_soon, + storePagesOnly: setting.woocommerce_store_pages_only, + privateLink: setting.woocommerce_private_link || 'no', + }; + + const currentValues = { comingSoon, storePagesOnly, privateLink }; + const saveButton = document.getElementsByClassName( + 'woocommerce-save-button' + )[ 0 ]; + if ( saveButton ) { + saveButton.disabled = + initValues.comingSoon === currentValues.comingSoon && + initValues.storePagesOnly === currentValues.storePagesOnly && + initValues.privateLink === currentValues.privateLink; + } + }, [ comingSoon, storePagesOnly, privateLink ] ); + const copyLink = __( 'Copy link', 'woocommerce' ); const copied = __( 'Copied!', 'woocommerce' ); const [ copyLinkText, setCopyLinkText ] = useState( copyLink ); diff --git a/plugins/woocommerce/changelog/47316-update-47304-disable-save-button-until-changes-are-made b/plugins/woocommerce/changelog/47316-update-47304-disable-save-button-until-changes-are-made new file mode 100644 index 00000000000..a2b85aac6c3 --- /dev/null +++ b/plugins/woocommerce/changelog/47316-update-47304-disable-save-button-until-changes-are-made @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +LYS: disables the "Save changes" button until changes are made. \ No newline at end of file