[WHIT-3323] Keep current url on rename#11445
Merged
Merged
Conversation
ddeaabd to
51fc4d5
Compare
ceae1ff to
4b09bdb
Compare
Replace the "Live page address" heading and govuk-hint URL with a "URL" heading and a paragraph containing the live URL as a clickable govuk-link, so editors can verify and visit the live page from the edit form. Coverage for the new markup is added in standard_editions_controller_test rather than document_collections_controller_test because the link is rendered by the shared _page_address_controls partial and standard_editions is now the more representative surface for partial-level UI coverage. The stale .govuk-hint assertion in document_collections_controller_test is dropped.
Swap the single "Keep the current page URL" checkbox for a pair of "Keep current URL" / "Update URL to match title" radios on the edit form, with a short paragraph above explaining the choice. The "Keep current URL" option is pre-checked when the user has either explicitly set slug_override OR when the draft's slug already matches the live edition's slug. This keeps the right option selected on freshly-loaded drafts with an unchanged title, on re-renders after validation failure, and on subsequent renames. Rename the JS variable from "checkbox" to "url-radio-group" so the reveal-on-title-change logic reads coherently against the new radio layout. Behaviour is unchanged: the controls stay hidden until the title diverges from its original value.
Reshape edition-update-slug.feature around two Rules: - The URL control only appears when the URL can be changed — covered by a @javascript scenario that confirms the keep-slug controls are hidden until the title is edited. - Renaming a draft keeps the live URL unless an editor opts out — four scenarios covering the simple keep / opt-out pair plus two force- publish round-trips where the chosen URL persists across subsequent renames. Replace the obsolete step set (visit_edit_slug, update_slug, the permission-denied step) with the steps the new scenarios rely on: seeing/not-seeing the keep-slug option, asserting the saved choice on re-entering edit, and two Given chains for the kept-URL / updated-URL force-publish setups. Adjust the preview-URL step to use Publication.latest_edition so it keeps working when a published edition and a new draft share the same title.
4b09bdb to
56a4bd5
Compare
Add a before_save :nullify_redundant_slug_override callback that nils slug_override whenever it equals the slug_from_title. The column then only ever holds a value that actually changes the resulting slug. Drafts whose user picked "Keep current URL" on a same-slug rename end up with slug_override = nil, as do form submits where the posted override happens to match the title, such as when the edition is edited but the title has not changed. Without this change we would end up with the slug_override matching the title based slug on a regular save which results in confusing data. The callback is declared between set_slug_from_title and set_slug so it sees the freshly-derived slug_from_title, and set_slug sees the finalised slug_override.
56a4bd5 to
0ac0a7d
Compare
TonyGDS
approved these changes
May 15, 2026
Contributor
TonyGDS
left a comment
There was a problem hiding this comment.
LGTM & @lauraghiorghisor-tw 🚢
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Previously, when the user changed the title of an edition in Whitehall, they were presented with a checkbox allowing them to preserve the document’s current live URL. If they did not check the box, the URL was updated to match the new title of the edition. Several departments have requested that we only update the edition's URL if the publisher specifically selects that behaviour.
The previous checkbox has been replaced by radio buttons, to better express what options the user has:
Keeping the live url is always our pre-checked option, unless the user has actively selected the title-based option.
The copy has been updated to reflect the new functionality. Feature tests now provide extensive coverage.
UI changes
Related PRs:
#11371
#11424
#11359
Jira