Skip to content

Improve brand colour inputs - #3082

Open
theseanything wants to merge 2 commits into
mainfrom
brand-colour-hex-input
Open

Improve brand colour inputs#3082
theseanything wants to merge 2 commits into
mainfrom
brand-colour-hex-input

Conversation

@theseanything

@theseanything theseanything commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Makes the brand colour fields easier to use:

  • Hex colour codes are now accepted in upper or lower case, with or without a leading #. Values are normalised before validation, so stored values keep the canonical lowercase #-prefixed form the runner API expects.
  • The colour inputs now show # as a text input prefix. The prefix is decorative and not submitted, which is why the form displays stored values without the leading # and the hint/error examples no longer include it. This suits how people usually copy hex codes: double-clicking one selects just the six characters, not the #, so pasted values typically arrive unprefixed.
image

Brand colours are normalised before validation, so uppercase hex
characters and a missing leading # no longer cause validation errors.
Stored values stay in the canonical lowercase #-prefixed form the
runner API and show page expect.
The prefix is decorative, so the form displays the stored colour
without its leading # and relies on the model normalising submitted
values. Hint and error text drop the # from the example to match
what users should now type.
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-3082.admin.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

@theseanything
theseanything marked this pull request as ready for review September 2, 2026 14:36
@theseanything
theseanything requested review from DavidBiddle and a lite review from Copilot September 2, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are cohesive, covered by updated specs, and the normalisation approach cleanly preserves the model’s existing validation contract while improving accepted input formats.

Pull request overview

This PR improves the UX and data consistency of Brand colour fields by allowing users to enter hex values in more common formats (with/without #, upper/lowercase) while normalising persisted values to the canonical #-prefixed lowercase form expected downstream.

Changes:

  • Normalises header_background_colour and border_colour before validation to # + lowercase, stripped 6-digit hex.
  • Updates the brand new/edit forms to use a decorative # prefix and to display stored values without the leading #.
  • Adjusts i18n hints/error messages and expands specs to cover the new accepted input variants and normalisation behavior.
File summaries
File Description
spec/requests/brands_controller_spec.rb Adds request coverage for creating a brand with uppercase/unprefixed colour input and verifying normalisation.
spec/models/brand_spec.rb Updates model validation expectations to accept multiple hex input formats and assert canonical normalised storage.
config/locales/en.yml Updates hint/error examples to match the new “no leading # in input” UI guidance.
app/views/brands/new.html.erb Adds # prefix UI and strips # from displayed values in the colour inputs.
app/views/brands/edit.html.erb Adds # prefix UI and strips # from displayed values in the colour inputs.
app/models/brand.rb Adds a before_validation normalisation step for colour attributes.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants