From 3ebb723c81991156bcd224dc299d73139ab9f3f8 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Wed, 22 Nov 2023 09:06:56 +0100 Subject: [PATCH] Don't render View Post button tooltip when show text labels is enabled. --- .../src/components/view-link/index.js | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/packages/edit-post/src/components/view-link/index.js b/packages/edit-post/src/components/view-link/index.js index 10b10d8af1ee3d..3ebf78b851e1f7 100644 --- a/packages/edit-post/src/components/view-link/index.js +++ b/packages/edit-post/src/components/view-link/index.js @@ -8,18 +8,28 @@ import { store as editorStore } from '@wordpress/editor'; import { store as coreStore } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../store'; + export default function ViewLink() { - const { permalink, isPublished, label } = useSelect( ( select ) => { - // Grab post type to retrieve the view_item label. - const postTypeSlug = select( editorStore ).getCurrentPostType(); - const postType = select( coreStore ).getPostType( postTypeSlug ); + const { permalink, isPublished, label, showIconLabels } = useSelect( + ( select ) => { + // Grab post type to retrieve the view_item label. + const postTypeSlug = select( editorStore ).getCurrentPostType(); + const postType = select( coreStore ).getPostType( postTypeSlug ); - return { - permalink: select( editorStore ).getPermalink(), - isPublished: select( editorStore ).isCurrentPostPublished(), - label: postType?.labels.view_item, - }; - }, [] ); + return { + permalink: select( editorStore ).getPermalink(), + isPublished: select( editorStore ).isCurrentPostPublished(), + label: postType?.labels.view_item, + showIconLabels: + select( editPostStore ).isFeatureActive( 'showIconLabels' ), + }; + }, + [] + ); // Only render the view button if the post is published and has a permalink. if ( ! isPublished || ! permalink ) { @@ -32,6 +42,7 @@ export default function ViewLink() { label={ label || __( 'View post' ) } href={ permalink } target="_blank" + showTooltip={ ! showIconLabels } /> ); }