Skip to content

Commit

Permalink
Don't render View Post button tooltip when show text labels is enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
afercia committed Nov 22, 2023
1 parent bd8f152 commit 3ebb723
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions packages/edit-post/src/components/view-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -32,6 +42,7 @@ export default function ViewLink() {
label={ label || __( 'View post' ) }
href={ permalink }
target="_blank"
showTooltip={ ! showIconLabels }
/>
);
}

0 comments on commit 3ebb723

Please sign in to comment.