aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/select/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/ui/select/index.tsx')
-rw-r--r--src/components/ui/select/index.tsx21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/components/ui/select/index.tsx b/src/components/ui/select/index.tsx
index c06ac59b0..0d8520f58 100644
--- a/src/components/ui/select/index.tsx
+++ b/src/components/ui/select/index.tsx
@@ -282,23 +282,23 @@ class SelectComponent extends Component<IProps, IState> {
282 282
283 if (!open) return; 283 if (!open) return;
284 284
285 if (e.keyCode === 38 || e.keyCode === 40) { 285 if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
286 e.preventDefault(); 286 e.preventDefault();
287 } 287 }
288 288
289 if (this.componentRef?.current) { 289 if (this.componentRef?.current) {
290 if (e.keyCode === 38 && selected > 0) { 290 if (e.key === 'ArrowUp' && selected > 0) {
291 this.setState((state: IState) => ({ 291 this.setState((state: IState) => ({
292 selected: state.selected - 1, 292 selected: state.selected - 1,
293 })); 293 }));
294 } else if ( 294 } else if (
295 e.keyCode === 40 && 295 e.key === 'ArrowDown' &&
296 selected < Object.keys(options!).length - 1 296 selected < Object.keys(options!).length - 1
297 ) { 297 ) {
298 this.setState((state: IState) => ({ 298 this.setState((state: IState) => ({
299 selected: state.selected + 1, 299 selected: state.selected + 1,
300 })); 300 }));
301 } else if (e.keyCode === 13) { 301 } else if (e.key === 'Enter') {
302 this.select(Object.keys(options!)[selected]); 302 this.select(Object.keys(options!)[selected]);
303 } 303 }
304 304
@@ -311,19 +311,6 @@ class SelectComponent extends Component<IProps, IState> {
311 this.scrollContainerRef.current.scrollTop = topOffset - 35; 311 this.scrollContainerRef.current.scrollTop = topOffset - 35;
312 } 312 }
313 } 313 }
314
315 switch (e.keyCode) {
316 case 37:
317 case 39:
318 case 38:
319 case 40: // Arrow keys
320 case 32: {
321 break;
322 } // Space
323 default: {
324 break;
325 } // do not block other keys
326 }
327 } 314 }
328 315
329 render(): ReactElement { 316 render(): ReactElement {