diff --git a/packages/edit-navigation/src/store/actions.js b/packages/edit-navigation/src/store/actions.js index e7e94d65ac7fb..587e4cf62e080 100644 --- a/packages/edit-navigation/src/store/actions.js +++ b/packages/edit-navigation/src/store/actions.js @@ -20,6 +20,7 @@ import { select, apiFetch, } from './controls'; +import { NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE } from '../constants'; import { menuItemsQuery, serializeProcessing, @@ -136,6 +137,16 @@ export const saveNavigationPost = serializeProcessing( function* ( post ) { throw new Error( batchSaveResponse.data.message ); } + // Clear "stub" navigation post edits to avoid a false "dirty" state. + yield dispatch( + 'core', + 'receiveEntityRecords', + NAVIGATION_POST_KIND, + NAVIGATION_POST_POST_TYPE, + [ post ], + undefined + ); + yield dispatch( noticesStore, 'createSuccessNotice', diff --git a/packages/edit-navigation/src/store/test/actions.js b/packages/edit-navigation/src/store/test/actions.js index c3e90091fccb2..0c2bf7c90f681 100644 --- a/packages/edit-navigation/src/store/test/actions.js +++ b/packages/edit-navigation/src/store/test/actions.js @@ -20,6 +20,10 @@ import { apiFetch, } from '../controls'; import { menuItemsQuery, computeCustomizedAttribute } from '../utils'; +import { + NAVIGATION_POST_KIND, + NAVIGATION_POST_POST_TYPE, +} from '../../constants'; jest.mock( '../utils', () => { const utils = jest.requireActual( '../utils' ); @@ -358,6 +362,17 @@ describe( 'saveNavigationPost', () => { ); expect( action.next( { success: true } ).value ).toEqual( + dispatch( + 'core', + 'receiveEntityRecords', + NAVIGATION_POST_KIND, + NAVIGATION_POST_POST_TYPE, + [ post ], + undefined + ) + ); + + expect( action.next().value ).toEqual( dispatch( noticesStore, 'createSuccessNotice',