-
Notifications
You must be signed in to change notification settings - Fork 334
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
Fix ‘backwards compatibility’ for the date input. #908
Conversation
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.
💯 Thanks for fixing this! good use of if not in
The previous implementation meant that if your input _does not_ have the name ‘year’ it would always get the class ‘govuk-input--width-2`. Because this class is defined last [1] – after every other width class – this makes it impossible to make any field that does not have the name ‘year’ use any other width than 2 characters. This commit addresses this by: - not adding a width class if any other width class is present within the `item.classes` (it’s relatively a naive check for the string ‘govuk-input--width-‘ but it should do the job) - only adding appropriate classes if the input has the name ‘day’, ‘month’ or ‘year’ It also adds tests for this behaviour. Fixes #907 [1]: https://github.com/alphagov/govuk-frontend/blob/8f2fe567865729716fa4a04b0c6eeb5860da7441/src/components/input/_input.scss#L71-L73
ac86ff8
to
2ea133f
Compare
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.
Great work, the test coverage makes this quite gnarly logic feel less daunting...
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.
LGTM 👍
The previous implementation meant that if your input does not have the name ‘year’ it would always get the class ‘govuk-input--width-2`.
Because this class is defined last – after every other width class – this makes it impossible to make any field that does not have the name ‘year’ use any other width than 2 characters.
This addresses this by:
item.classes
(it’s relatively a naive check for the string ‘govuk-input--width-‘ but it should do the job)It also adds tests for this behaviour.
Fixes #907