Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Update displayed permalink when slug is cleared #11783
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
How has this been tested?
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.
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.
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.
I think this is ready for a review.