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

Remove pattern attribute from date input component #2599

Merged
merged 1 commit into from
Apr 25, 2022
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ If you're not using the Nunjucks macros, remove the `aria-live` attribute from t

This change was introduced in [pull request #2577: Refactor character count to inject new element](https://github.com/alphagov/govuk-frontend/pull/2577)

#### Remove `pattern` from the date input component

If you're not using the Nunjucks macros, remove `pattern="[0-9]*"` from each of the date input component's elements.

This attribute was originally added to enforce numeric keyboard functionality in Safari on iOS. The `inputmode` attribute provides this functionality for newer Safari versions, so we no longer need to use the `pattern` attribute.

This change was introduced in [pull request #2599: Remove pattern attribute from date input component](https://github.com/alphagov/govuk-frontend/pull/2599).

### Fixes

We've made the following fixes in [pull request #2577: Refactor character count to inject new element](https://github.com/alphagov/govuk-frontend/pull/2577):
Expand Down
2 changes: 1 addition & 1 deletion src/govuk/components/date-input/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
type: "text",
inputmode: item.inputmode if item.inputmode else "numeric",
autocomplete: item.autocomplete,
pattern: item.pattern if item.pattern else "[0-9]*",
pattern: item.pattern,
attributes: item.attributes
}) | indent(6) | trim }}
</div>
Expand Down
7 changes: 0 additions & 7 deletions src/govuk/components/date-input/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ describe('Date input', () => {
expect($firstInput.attr('inputmode')).toEqual('numeric')
})

it('renders inputs with pattern="[0-9]*" to trigger numeric keypad on iOS', () => {
const $ = render('date-input', examples.default)

const $firstInput = $('.govuk-date-input__item:first-child input')
expect($firstInput.attr('pattern')).toEqual('[0-9]*')
})

it('renders item with implicit class for label', () => {
const $ = render('date-input', examples.default)

Expand Down