Skip to content

Commit

Permalink
Merge pull request #1527 from htmlandbacon/feature/adding-input-mode
Browse files Browse the repository at this point in the history
Adding inputmode option to input component
  • Loading branch information
NickColley authored Aug 27, 2019
2 parents 5a514ce + cfe1935 commit 1891865
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

## Unreleased

### Inputmode

Adds the ability to pass an optional [inputmode](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode) into the input component

```javascript
govukInput({
inputmode: 'email'
})
```

- [Pull request #1527: Adding inputmode to input component](https://github.com/alphagov/govuk-frontend/pull/1527)


### Fixes

- [Pull request #1512: Update components to only output items when they are defined](https://github.com/alphagov/govuk-frontend/pull/1512).
Expand Down
4 changes: 4 additions & 0 deletions src/govuk/components/input/input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ params:
type: string
required: false
description: Type of input control to render. Defaults to "text".
- name: inputmode
type: string
require: false
description: Optional value for [inputmode](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode).
- name: value
type: string
required: false
Expand Down
1 change: 1 addition & 0 deletions src/govuk/components/input/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
{%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %}
{%- if params.autocomplete %} autocomplete="{{ params.autocomplete}}"{% endif %}
{%- if params.pattern %} pattern="{{ params.pattern }}"{% endif %}
{%- if params.inputmode %} inputmode="{{ params.inputmode }}"{% endif %}
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}>
</div>
11 changes: 11 additions & 0 deletions src/govuk/components/input/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,15 @@ describe('Input', () => {
expect($component.attr('autocomplete')).toEqual('postal-code')
})
})

describe('when it includes an inputmode', () => {
it('renders with an inputmode attached to the input', () => {
const $ = render('input', {
inputmode: 'decimal'
})

const $component = $('.govuk-form-group > .govuk-input')
expect($component.attr('inputmode')).toEqual('decimal')
})
})
})

0 comments on commit 1891865

Please sign in to comment.