Add post title link in template editor#66305
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Thanks for the review @akasunil. I am not sure about the correct approach as to how to refactor the code, It seems all the conditions are necessary and we can not merge them easily. Can you share your thoughts? |
| /* If the postType or postId is not set, It might be in template editor. Just show the title as a link. | ||
| * This is a fallback for the case where the postType and postId are not set. | ||
| */ | ||
| titleElement = ( |
There was a problem hiding this comment.
I agree with @akasunil that we should refactor in here, but at least for this PR we could just:
let titleElement = ! isLink ? (
<TagName { ...blockProps }>{ __( 'Title' ) }</TagName>
) : (
<TagName { ...blockProps }>
<a
href="#post-title-pseudo-link"
onClick={ ( event ) => event.preventDefault() }
>
{ __( 'Title' ) }
</a>
</TagName>
);
when we set the default titleElement above (let titleElement = <TagName { ...blockProps }>{ __( 'Title' ) }</TagName>;). Note that we don't need all a attributes and not dangerouslySetInnerHTML.
@imrraaj it seems it's been a while for this PR, but can you update and rebase in order to land?
What?
This PR adds the link tag to post title when selected in the template editor.
For better understanding go through the issue
Why?
Fixes: #65691
How?
This PR adds the necessary anchor tag when we have link option enabled.
Testing Instructions
Screenshots or screencast
Before
After