-
Notifications
You must be signed in to change notification settings - Fork 331
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
Enable pattern
attribute for input (+ custom date input attributes)
#1172
Enable pattern
attribute for input (+ custom date input attributes)
#1172
Conversation
This would fix #995, if we're happy with this as a solution. I am a little concerned about users forgetting (or not realising) that they need to pass in the |
1cbfc9e
to
6d4ad96
Compare
@36degrees Yeah I thought the same. I added a new global called Would have been like: {
autocomplete: item.autocomplete,
attributes: merge(item.attributes, { pattern: "[0-9]*" })
} Sadly nunjucks doesn't provide object merging. |
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.
We want to add maxlength to the fields, as this worked much better in testing. However this requires the type to not be number as you can't set a maxlength for number fields (although you can set a min and max with some success)
6d4ad96
to
a37d7c0
Compare
This is the same way I have done it in my forked version of |
a37d7c0
to
b4be3e8
Compare
Rebased with latest |
Hanna and I have reviewed this, we like this approach but want to consider the others too. If we were to go with this approach we'd need to update the YAML description to be clear that setting this attributes requires you to add You can see #995 (comment) for more details on what we've talked about. |
3df9ebb
to
35459df
Compare
@NickColley @hannalaakso If you'd like to go with this approach, I've updated both the yaml description and changelog entry to include Looking forward to seeing |
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.
I think this is a good compromise that will also unblock @malcolmhire and we can still consider a more robust developer friendly way in the future as discussed.
The work itself is clearly documented at the point of use, and implemented well with tests, thanks a lot for this Colin.
Will require a second review.
35459df
to
e4485b5
Compare
I've talked this through with the team and we think there's an alternative to this that avoids some of the negative aspects of this approach without making breaking changes: |
pattern
attribute for input (+ custom date input attributes)
@@ -162,3 +166,11 @@ examples: | |||
id: input-with-autocomplete-attribute | |||
name: postcode | |||
autocomplete: postal-code | |||
- name: with pattern attribute |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
I've reviewed the live examples and they are outputting correctly.
And the api changes to the macros look great.
There's a lot going on here though so would appreciate another proper good look from someone on the team.
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.
Looks good to me, thanks @colinrotherham 👍
I've added one minor comment about one of the tests, but happy to merge as-is if you prefer.
178afb8
to
b863be5
Compare
Thanks @36degrees. I've removed that extra assertion, it was definitely already covered. All ready to merge if you're happy 😊 |
Going to run out of superlatives to describe these pull requests thanks so much for your help Colin. 👏 |
We're converting a service from GOV.UK Elements to GOV.UK Frontend and noticed we can't provide custom attributes to our day/month/year fields.
Here's a pull request to add the feature.
As there's no "object merge" nunjucks filter the
pattern: '[0-9]*'
default attribute must be added manually when the entire attributes object is overridden from the defaults.