From: Mathieu Suen Date: Fri, 7 Oct 2022 08:32:01 +0000 (+0200) Subject: SONAR-16946 Function cannot be performed by keyboard alone X-Git-Tag: 9.7.0.61563~110 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c8fc1658174315adf2be93ee931b6753d230bac3;p=sonarqube.git SONAR-16946 Function cannot be performed by keyboard alone --- 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; };