Skip to content

Commit 4d9738e

Browse files
authored
Update TimePicker.jsx
1 parent 574c2aa commit 4d9738e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/TimePicker.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ export default class Picker extends Component {
126126
this.focus();
127127
}
128128

129+
onTab = (toPrevious) => {
130+
this.setOpen(false);
131+
132+
const allInputs = document.querySelectorAll('input');
133+
for (let i = 0; i < allInputs.length; i++) {
134+
if (allInputs[i] === this.picker) {
135+
if (toPrevious === true && i !== 0) {
136+
allInputs[i - 1].focus();
137+
} else if (i !== allInputs.length - 1) {
138+
allInputs[i + 1].focus();
139+
}
140+
break;
141+
}
142+
}
143+
}
144+
129145
onKeyDown = (e) => {
130146
if (e.keyCode === 40) {
131147
this.setOpen(true);
@@ -184,6 +200,7 @@ export default class Picker extends Component {
184200
showMinute={showMinute}
185201
showSecond={showSecond}
186202
onEsc={this.onEsc}
203+
onTab={this.onTab}
187204
allowEmpty={allowEmpty}
188205
format={this.getFormat()}
189206
placeholder={placeholder}

0 commit comments

Comments
 (0)