Skip to content

Commit

Permalink
Commands: Use the same Preview target tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Aug 1, 2023
1 parent d3c6ce8 commit 0201315
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 0201315

Please sign in to comment.