From 960a0c3002da274cfa83b353c5f871449fb9af85 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 3 Aug 2023 01:30:56 +0400 Subject: [PATCH] Commands: Use the same Preview target tab (#53242) --- .../edit-post/src/hooks/commands/use-common-commands.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/edit-post/src/hooks/commands/use-common-commands.js b/packages/edit-post/src/hooks/commands/use-common-commands.js index d07f9695c4dcf7..7dd45aa83f9daf 100644 --- a/packages/edit-post/src/hooks/commands/use-common-commands.js +++ b/packages/edit-post/src/hooks/commands/use-common-commands.js @@ -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', @@ -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 }` ); }, } ); }