From e32a9797880b10285cd97d99b65dce499772be4d Mon Sep 17 00:00:00 2001 From: Dhananjay Kuber Date: Wed, 15 Jan 2025 12:00:26 +0530 Subject: [PATCH] fix: PostPreviewButton previewLink assignment based on viewable status --- .../editor/src/components/post-preview-button/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/post-preview-button/index.js b/packages/editor/src/components/post-preview-button/index.js index d1755f96b6861..83181191b0c5f 100644 --- a/packages/editor/src/components/post-preview-button/index.js +++ b/packages/editor/src/components/post-preview-button/index.js @@ -130,12 +130,17 @@ export default function PostPreviewButton( { editor.getCurrentPostType( 'type' ) ); + const canView = postType?.viewable ?? false; + const previewUrl = canView + ? editor.getEditedPostPreviewLink() + : null; + return { postId: editor.getCurrentPostId(), currentPostLink: editor.getCurrentPostAttribute( 'link' ), - previewLink: editor.getEditedPostPreviewLink(), + previewLink: previewUrl, isSaveable: editor.isEditedPostSaveable(), - isViewable: postType?.viewable ?? false, + isViewable: canView, }; }, [] );