-
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
Update displayed permalink when slug is cleared #11783
Conversation
Hmm, |
I'm going to take a different approach on this that doesn't manipulate |
5451d29
to
0c52144
Compare
I refactored this to stop editing |
I just opened #12009, which goes a good bit further than this one on improvements. Let's evaluate both and discuss plans for the future of the title permalink component. That will dictate how we handle reusing some of the logic in the new sidebar permalink panel. |
* | ||
* @return {string} Processed string | ||
*/ | ||
export function cleanForSlug( string ) { |
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.
Seems like a good candidate for a unit test
Thanks @youknowriad. Suggestions look good and I can make those changes. I'm curious whether #12009 is realistic or if you'd rather just ship a fix for this and continue to iterate on something like that. The same clearing slug problem exists in the sidebar panel, so we should probably fix it there at the same time as this because otherwise it will be pretty confusing. Want me to add that to this PR? |
Yes please, that would be ace
I'm not certain I understand this PR properly yet to give a proper answer and also I don't feel like I'm the right person for it as it couches some existing core PHP logic. |
0c52144
to
673a2fa
Compare
I think this is ready for a review.
|
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.
Works great on my testing. Thanks
As a follow-up, it might be a good idea to add an e2e test. |
Description
Closes #7002.
This does a simple fix of the issue in #7002 where a permalink slug appears to stay the same after it is cleared, when it should be generated based off of what is in the title.
With this fix, if the post has not been published yet and the slug has not been manually customized, then the slug continually updates to reflect what is in the post title. Once it's published or the slug is manually edited, it will be frozen to that value. If cleared, it will go back to auto-rendering based off the post title. This is technically the same save functionality as before, it's just displaying a closer representation to the actual value that will be saved.
I also improved on the existing slug cleaning a bit, without going all the way to a full recreation of
sanitize_title()
in JS. (I also didn't want to call the utility functionsanitizeTitle
for that reason. If someone has a better name suggestion, please let me know.)How has this been tested?
Screenshots
Additional Notes
Even with this change, we still have some work to do to achieve feature parity between the old and new editor when it comes to editing the permalink. As it stands, it can't be edited until a manual save has occurred, which is confusing. Ideally it would become editable on blur from the title, as it was before. However, in order to do that, we need it to be able treat it like a preview link for autosaves and drafts, since the actual permalink URL won't be available yet.
I think the ideal fix here is to abstract out the preview link functionality from the preview button component and allow it to be reused here, but that might need to just be a future enhancement post 5.0. This will work in the short-term to improve the permalink editor.
Fixes #7002