-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert post title instead of URL, when adding a link to an existing post #21240
Conversation
This seems like a sensible change to me. I know there's been some history with the suggestion title and wanting to avoid some of its applications (#19735, #19739), but in terms of a default text for a new link, it seems like a good option to use as a default. My only concern would be if a manually entered URL (as in a user pasting a URL to the input field) would be selected and have an associated title, it's not clear to me if the user would expect the title to be used, or the URL. I don't know that it's currently the case that a title is assigned in these instances, however. |
There's unfortunately not any useful unit tests associated with this code. However, there is a pretty exhaustive suite of end-to-end tests for links: It would be good if we could account for this new behavior somewhere in those tests. Depending on whether you're using the default development environment, it could be a little bit of extra work to get the end-to-end tests running in your environment: https://github.com/WordPress/gutenberg/blob/master/packages/scripts/README.md#test-e2e Is that something you might be interested in taking on? Let me know if I can help. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank for submitting this PR. It's very much appreciated 👍
I agree with @aduth that this seems like a sensible change. We should be aware of edge cases and try and include these in the e2e tests he references.
I did spot one bug. If you create some Pages with long titles then when the link is created only part of the title
gets marked as the hyperlink. I'm not sure if that's a bug with this or a wider bug that exists in master
.
Also made code a bit more readable
@getdave Nice find. fixed it. Looks like the formatting was still applied to the length of the URL, I changed it to the length of the inner text now. Also did a quick find for other places where the newUrl was used. I think we're good now. @aduth I'm using the default |
@aduth I might need some help. All tests keep failing with this message: I'll look into the error tomorrow. Probably something stupid. Maybe you know a quick fix? |
@pwkip I believe this issue may be because the built copy of Gutenberg is generated from Related:
Short-term, you can probably resolve this by running |
@aduth I've created a new test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks and works great! Thanks, and congratulations on your first contribution! 🎉
Congratulations on your first merged pull request! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
@aduth Thanks for the follow up and all your helpful feedback! I learned a lot and hope to contribute more in the future. 👍 |
Congratulations on your PR acceptance @pwkip! |
Fixes #11930
Make the link anchor also retrieve the title of the post/page
Description
How has this been tested?
Tested on local development server. Tested the following cases:
Screenshots
Types of changes
New feature
Checklist: