]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15575 Fix keyboard navigation in hotspots page
authorJeremy Davis <jeremy.davis@sonarsource.com>
Thu, 4 Nov 2021 14:51:13 +0000 (15:51 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 4 Nov 2021 20:03:25 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.tsx

index 300d2e53178125154b462b0254083a54c0d19c01..6751bb68ab7f1ca94d046875146bf22c2c98aad3 100644 (file)
@@ -46,6 +46,8 @@ interface State {
   showStatusUpdateSuccessModal: boolean;
 }
 
+const SCROLL_TO_COMMENT_BOTTOM_OFFSET = 300;
+
 export default class HotspotViewer extends React.PureComponent<Props, State> {
   mounted = false;
   state: State;
@@ -66,9 +68,6 @@ export default class HotspotViewer extends React.PureComponent<Props, State> {
     if (prevProps.hotspotKey !== this.props.hotspotKey) {
       this.fetchHotspot();
     }
-    if (this.commentTextRef.current) {
-      this.commentTextRef.current.focus({ preventScroll: true });
-    }
   }
 
   componentWillUnmount() {
@@ -102,7 +101,7 @@ export default class HotspotViewer extends React.PureComponent<Props, State> {
     if (this.commentTextRef.current) {
       this.commentTextRef.current.focus({ preventScroll: true });
       scrollToElement(this.commentTextRef.current, {
-        bottomOffset: 100
+        bottomOffset: SCROLL_TO_COMMENT_BOTTOM_OFFSET
       });
     }
   };