Skip to content
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

Update date input to use type=text and inputmode=numeric #1704

Merged
merged 3 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ If you're using Nunjucks, you can now add classes to the character count compone

### Fixes

- [Pull request #1704: Update the date input component to use `input type=text inputmode=numeric`](https://github.com/alphagov/govuk-frontend/pull/1704)
- [Pull request #1690: Don't unneccesarily self-close tags](https://github.com/alphagov/govuk-frontend/pull/1690)
- [Pull request #1678: Fix tabs component throwing JavaScript errors in Internet Explorer 8](https://github.com/alphagov/govuk-frontend/pull/1678).
- [Pull request #1676: Fix skip link component focus style with global styles enabled](https://github.com/alphagov/govuk-frontend/pull/1676).
Expand Down
3 changes: 2 additions & 1 deletion src/govuk/components/date-input/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
classes: "govuk-date-input__input " + (item.classes if item.classes),
name: (params.namePrefix + "-" + item.name) if params.namePrefix else item.name,
value: item.value,
type: "number",
type: "text",
inputmode: "numeric",
autocomplete: item.autocomplete,
pattern: item.pattern if item.pattern else "[0-9]*",
attributes: item.attributes
Expand Down
17 changes: 15 additions & 2 deletions src/govuk/components/date-input/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('Date input', () => {
expect($firstItems.text().trim()).toEqual('Day')
})

it('renders inputs with type="number"', () => {
it('renders inputs with type="text"', () => {
const $ = render('date-input', {
items: [
{
Expand All @@ -150,7 +150,20 @@ describe('Date input', () => {
})

const $firstInput = $('.govuk-date-input__item:first-child input')
expect($firstInput.attr('type')).toEqual('number')
expect($firstInput.attr('type')).toEqual('text')
})

it('renders inputs with inputmode="numeric"', () => {
const $ = render('date-input', {
items: [
{
name: 'day'
}
]
})

const $firstInput = $('.govuk-date-input__item:first-child input')
expect($firstInput.attr('inputmode')).toEqual('numeric')
})

it('renders inputs with pattern="[0-9]*" to trigger numeric keypad on iOS', () => {
Expand Down