diff --git a/packages/edit-navigation/src/components/header/save-button.js b/packages/edit-navigation/src/components/header/save-button.js index 4d526ebbe40ed3..0ab895f6746dec 100644 --- a/packages/edit-navigation/src/components/header/save-button.js +++ b/packages/edit-navigation/src/components/header/save-button.js @@ -1,9 +1,10 @@ /** * WordPress dependencies */ -import { useDispatch } from '@wordpress/data'; +import { useDispatch, useSelect } from '@wordpress/data'; import { Button } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; +import { store as coreStore } from '@wordpress/core-data'; /** * Internal dependencies @@ -11,8 +12,19 @@ import { __ } from '@wordpress/i18n'; import { store as editNavigationStore } from '../../store'; export default function SaveButton( { navigationPost } ) { + const { isDirty } = useSelect( ( select ) => { + const { __experimentalGetDirtyEntityRecords } = select( coreStore ); + const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); + + return { + isDirty: dirtyEntityRecords.length > 0, + }; + }, [] ); + const { saveNavigationPost } = useDispatch( editNavigationStore ); + const disabled = ! isDirty || ! navigationPost; + return (