Skip to content

Commit

Permalink
Commands: Use the same Preview target tab (#53242)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Aug 2, 2023
1 parent ae4385a commit 960a0c3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/edit-post/src/hooks/commands/use-common-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default function useCommonCommands() {
const { toggle } = useDispatch( preferencesStore );
const { createInfoNotice } = useDispatch( noticesStore );
const { __unstableSaveForPreview } = useDispatch( editorStore );
const { getCurrentPostId } = useSelect( editorStore );

useCommand( {
name: 'core/open-settings-sidebar',
Expand Down Expand Up @@ -214,8 +215,9 @@ export default function useCommonCommands() {
icon: external,
callback: async ( { close } ) => {
close();
const link = await __unstableSaveForPreview( {} );
window.open( link, '_blank' );
const postId = getCurrentPostId();
const link = await __unstableSaveForPreview();
window.open( link, `wp-preview-${ postId }` );
},
} );
}

0 comments on commit 960a0c3

Please sign in to comment.