From c8fc1658174315adf2be93ee931b6753d230bac3 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Fri, 7 Oct 2022 10:32:01 +0200 Subject: [PATCH] SONAR-16946 Function cannot be performed by keyboard alone --- .../src/main/js/components/common/MultiSelect.tsx | 2 +- .../js/components/hoc/withKeyboardNavigation.tsx | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/server/sonar-web/src/main/js/components/common/MultiSelect.tsx b/server/sonar-web/src/main/js/components/common/MultiSelect.tsx index 703df7b833f..ff01303af80 100644 --- a/server/sonar-web/src/main/js/components/common/MultiSelect.tsx +++ b/server/sonar-web/src/main/js/components/common/MultiSelect.tsx @@ -118,7 +118,7 @@ export default class MultiSelect extends React.PureComponent( return true; } if (event.key === KeyboardKeys.UpArrow) { - event.preventDefault(); - return this.skipIfFile(this.handleHighlightPrevious); + return this.skipIfFile(event, this.handleHighlightPrevious); } else if (event.key === KeyboardKeys.DownArrow) { - event.preventDefault(); - return this.skipIfFile(this.handleHighlightNext); + return this.skipIfFile(event, this.handleHighlightNext); } else if (event.key === KeyboardKeys.RightArrow || event.key === KeyboardKeys.Enter) { - event.preventDefault(); - return this.skipIfFile(this.handleSelectCurrent); + return this.skipIfFile(event, this.handleSelectCurrent); } else if (event.key === KeyboardKeys.LeftArrow) { - event.preventDefault(); this.handleSelectParent(); return false; // always hijack left / Why did you put this @wouter? } - return false; + return true; }; getCurrentIndex = () => { @@ -81,10 +77,11 @@ export default function withKeyboardNavigation

( : -1; }; - skipIfFile = (handler: () => void) => { + skipIfFile = (event: KeyboardEvent, handler: () => void) => { if (this.props.isFile) { return true; } + event.preventDefault(); handler(); return false; }; -- 2.39.5