Skip to content

Commit df2df4f

Browse files
committed
Add pattern defaultProp
1 parent 6d5dac8 commit df2df4f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
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
@@ -20,6 +20,7 @@ exports[`DateInput matches snapshot 1`] = `
2020
<Component>
2121
<IndividualDateInput
2222
inputType="day"
23+
pattern="[0-9]*"
2324
>
2425
<div
2526
className="nhsuk-date-input__item"
@@ -52,6 +53,7 @@ exports[`DateInput matches snapshot 1`] = `
5253
id="testInput-day"
5354
name="testInput-day"
5455
onChange={[Function]}
56+
pattern="[0-9]*"
5557
/>
5658
</div>
5759
</div>
@@ -60,6 +62,7 @@ exports[`DateInput matches snapshot 1`] = `
6062
<Component>
6163
<IndividualDateInput
6264
inputType="month"
65+
pattern="[0-9]*"
6366
>
6467
<div
6568
className="nhsuk-date-input__item"
@@ -92,6 +95,7 @@ exports[`DateInput matches snapshot 1`] = `
9295
id="testInput-month"
9396
name="testInput-month"
9497
onChange={[Function]}
98+
pattern="[0-9]*"
9599
/>
96100
</div>
97101
</div>
@@ -100,6 +104,7 @@ exports[`DateInput matches snapshot 1`] = `
100104
<Component>
101105
<IndividualDateInput
102106
inputType="year"
107+
pattern="[0-9]*"
103108
>
104109
<div
105110
className="nhsuk-date-input__item"
@@ -132,6 +137,7 @@ exports[`DateInput matches snapshot 1`] = `
132137
id="testInput-year"
133138
name="testInput-year"
134139
onChange={[Function]}
140+
pattern="[0-9]*"
135141
/>
136142
</div>
137143
</div>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ const IndividualDateInput: React.FC<IndividualDateInputProps> = ({
9393
);
9494
};
9595

96+
IndividualDateInput.defaultProps = {
97+
pattern: '[0-9]*',
98+
};
99+
96100
export const DayInput: React.FC<Omit<IndividualDateInputProps, 'inputType'>> = props => (
97101
<IndividualDateInput inputType="day" {...props} />
98102
);

0 commit comments

Comments
 (0)