File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
src/components/date-input Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ exports[`DateInput matches snapshot 1`] = `
2121 <IndividualDateInput
2222 inputType = " day"
2323 pattern = " [0-9]*"
24+ type = " number"
2425 >
2526 <div
2627 className = " nhsuk-date-input__item"
@@ -54,6 +55,7 @@ exports[`DateInput matches snapshot 1`] = `
5455 name = " testInput-day"
5556 onChange = { [Function ]}
5657 pattern = " [0-9]*"
58+ type = " number"
5759 />
5860 </div >
5961 </div >
@@ -63,6 +65,7 @@ exports[`DateInput matches snapshot 1`] = `
6365 <IndividualDateInput
6466 inputType = " month"
6567 pattern = " [0-9]*"
68+ type = " number"
6669 >
6770 <div
6871 className = " nhsuk-date-input__item"
@@ -96,6 +99,7 @@ exports[`DateInput matches snapshot 1`] = `
9699 name = " testInput-month"
97100 onChange = { [Function ]}
98101 pattern = " [0-9]*"
102+ type = " number"
99103 />
100104 </div >
101105 </div >
@@ -105,6 +109,7 @@ exports[`DateInput matches snapshot 1`] = `
105109 <IndividualDateInput
106110 inputType = " year"
107111 pattern = " [0-9]*"
112+ type = " number"
108113 >
109114 <div
110115 className = " nhsuk-date-input__item"
@@ -138,6 +143,7 @@ exports[`DateInput matches snapshot 1`] = `
138143 name = " testInput-year"
139144 onChange = { [Function ]}
140145 pattern = " [0-9]*"
146+ type = " number"
141147 />
142148 </div >
143149 </div >
Original file line number Diff line number Diff line change @@ -44,8 +44,8 @@ const IndividualDateInput: React.FC<IndividualDateInputProps> = ({
4444
4545 const inputID = id || `${ ctxId } -${ inputType } ` ;
4646 const inputName = name || `${ ctxName } -${ inputType } ` ;
47- const inputValue = value || ctxValue ?. [ inputType ] || undefined ;
48- const inputDefaultValue = defaultValue || ctxDefaultValue ?. [ inputType ] || undefined ;
47+ const inputValue = value !== undefined ? value : ctxValue ?. [ inputType ] ;
48+ const inputDefaultValue = defaultValue !== undefined ? defaultValue : ctxDefaultValue ?. [ inputType ] ;
4949
5050 const handleChange = ( e : ChangeEvent < HTMLInputElement > ) => {
5151 e . persist ( ) ;
@@ -95,6 +95,7 @@ const IndividualDateInput: React.FC<IndividualDateInputProps> = ({
9595
9696IndividualDateInput . defaultProps = {
9797 pattern : '[0-9]*' ,
98+ type : 'number' ,
9899} ;
99100
100101export const DayInput : React . FC < Omit < IndividualDateInputProps , 'inputType' > > = props => (
You can’t perform that action at this time.
0 commit comments