Skip to content

Commit aef9215

Browse files
committed
Implement proper hour picker when minute picking is disabled in native input
1 parent 698d75b commit aef9215

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/DateTimeInput/NativeInput.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,25 @@ import { isMaxDate, isMinDate } from '../shared/propTypes';
77
const nativeValueParser = getISOLocalDateTime;
88

99
export default class NativeInput extends PureComponent {
10+
get step() {
11+
const { valueType } = this.props;
12+
13+
switch (valueType) {
14+
case 'hour':
15+
return 3600;
16+
case 'minute':
17+
return 60;
18+
case 'second':
19+
return 1;
20+
default:
21+
throw new Error('Invalid valueType.');
22+
}
23+
}
24+
1025
stopPropagation = event => event.stopPropagation();
1126

1227
render() {
28+
const { step } = this;
1329
const {
1430
disabled, maxDate, minDate, name, onChange, required, value,
1531
} = this.props;
@@ -24,6 +40,7 @@ export default class NativeInput extends PureComponent {
2440
onChange={onChange}
2541
onFocus={this.stopPropagation}
2642
required={required}
43+
step={step}
2744
style={{
2845
visibility: 'hidden',
2946
position: 'absolute',

0 commit comments

Comments
 (0)