diff --git a/packages/data/src/plugins/persistence/index.js b/packages/data/src/plugins/persistence/index.js index 30ac60abbc3cc7..75fe54a394efed 100644 --- a/packages/data/src/plugins/persistence/index.js +++ b/packages/data/src/plugins/persistence/index.js @@ -246,6 +246,26 @@ persistencePlugin.__unstableMigrate = ( pluginOptions ) => { } ); } + let editPostState = state[ 'core/edit-post' ]; + + // Default `fullscreenMode` to `false` if any persisted state had existed + // and the user hadn't made an explicit choice about fullscreen mode. This + // is needed since `fullscreenMode` previously did not have a default value + // and was implicitly false by its absence. It is now `true` by default, but + // this change is not intended to affect upgrades from earlier versions. + const hadPersistedState = Object.keys( state ).length > 0; + const hadFullscreenModePreference = has( state, [ + 'core/edit-post', + 'preferences', + 'features', + 'fullscreenMode', + ] ); + if ( hadPersistedState && ! hadFullscreenModePreference ) { + editPostState = merge( {}, editPostState, { + preferences: { features: { fullscreenMode: false } }, + } ); + } + // Migrate 'areTipsEnabled' from 'core/nux' to 'showWelcomeGuide' in 'core/edit-post' const areTipsEnabled = get( state, [ 'core/nux', @@ -259,16 +279,17 @@ persistencePlugin.__unstableMigrate = ( pluginOptions ) => { 'welcomeGuide', ] ); if ( areTipsEnabled !== undefined && ! hasWelcomeGuide ) { - persistence.set( - 'core/edit-post', - merge( state[ 'core/edit-post' ], { - preferences: { - features: { - welcomeGuide: areTipsEnabled, - }, + editPostState = merge( {}, editPostState, { + preferences: { + features: { + welcomeGuide: areTipsEnabled, }, - } ) - ); + }, + } ); + } + + if ( editPostState !== state[ 'core/edit-post' ] ) { + persistence.set( 'core/edit-post', editPostState ); } };