Skip to content

Commit 873606c

Browse files
committed
Add inputMode to DateInput
1 parent 3345d95 commit 873606c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/components/date-input/__tests__/__snapshots__/DateInput.test.tsx.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ exports[`DateInput matches snapshot 1`] = `
1919
>
2020
<Component>
2121
<IndividualDateInput
22+
inputMode="numeric"
2223
inputType="day"
2324
pattern="[0-9]*"
2425
type="number"
@@ -52,6 +53,7 @@ exports[`DateInput matches snapshot 1`] = `
5253
aria-labelledby="testInput-day--label"
5354
className="nhsuk-input nhsuk-date-input__input nhsuk-input--width-2"
5455
id="testInput-day"
56+
inputMode="numeric"
5557
name="testInput-day"
5658
onChange={[Function]}
5759
pattern="[0-9]*"
@@ -63,6 +65,7 @@ exports[`DateInput matches snapshot 1`] = `
6365
</Component>
6466
<Component>
6567
<IndividualDateInput
68+
inputMode="numeric"
6669
inputType="month"
6770
pattern="[0-9]*"
6871
type="number"
@@ -96,6 +99,7 @@ exports[`DateInput matches snapshot 1`] = `
9699
aria-labelledby="testInput-month--label"
97100
className="nhsuk-input nhsuk-date-input__input nhsuk-input--width-2"
98101
id="testInput-month"
102+
inputMode="numeric"
99103
name="testInput-month"
100104
onChange={[Function]}
101105
pattern="[0-9]*"
@@ -107,6 +111,7 @@ exports[`DateInput matches snapshot 1`] = `
107111
</Component>
108112
<Component>
109113
<IndividualDateInput
114+
inputMode="numeric"
110115
inputType="year"
111116
pattern="[0-9]*"
112117
type="number"
@@ -140,6 +145,7 @@ exports[`DateInput matches snapshot 1`] = `
140145
aria-labelledby="testInput-year--label"
141146
className="nhsuk-input nhsuk-date-input__input nhsuk-input--width-4"
142147
id="testInput-year"
148+
inputMode="numeric"
143149
name="testInput-year"
144150
onChange={[Function]}
145151
pattern="[0-9]*"

src/components/date-input/components/IndividualDateInputs.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const IndividualDateInput: React.FC<IndividualDateInputProps> = ({
4545
const inputID = id || `${ctxId}-${inputType}`;
4646
const inputName = name || `${ctxName}-${inputType}`;
4747
const inputValue = value !== undefined ? value : ctxValue?.[inputType];
48-
const inputDefaultValue = defaultValue !== undefined ? defaultValue : ctxDefaultValue?.[inputType];
48+
const inputDefaultValue =
49+
defaultValue !== undefined ? defaultValue : ctxDefaultValue?.[inputType];
4950

5051
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
5152
e.persist();
@@ -95,6 +96,7 @@ const IndividualDateInput: React.FC<IndividualDateInputProps> = ({
9596

9697
IndividualDateInput.defaultProps = {
9798
pattern: '[0-9]*',
99+
inputMode: 'numeric',
98100
type: 'number',
99101
};
100102

0 commit comments

Comments
 (0)