From: Jeremy Davis Date: Thu, 4 Nov 2021 14:51:13 +0000 (+0100) Subject: SONAR-15575 Fix keyboard navigation in hotspots page X-Git-Tag: 9.2.0.49834~76 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c8fdeae6c3ce695ca3e3ce448cbd917124a27646;p=sonarqube.git SONAR-15575 Fix keyboard navigation in hotspots page --- diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.tsx index 300d2e53178..6751bb68ab7 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.tsx @@ -46,6 +46,8 @@ interface State { showStatusUpdateSuccessModal: boolean; } +const SCROLL_TO_COMMENT_BOTTOM_OFFSET = 300; + export default class HotspotViewer extends React.PureComponent { mounted = false; state: State; @@ -66,9 +68,6 @@ export default class HotspotViewer extends React.PureComponent { 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 { if (this.commentTextRef.current) { this.commentTextRef.current.focus({ preventScroll: true }); scrollToElement(this.commentTextRef.current, { - bottomOffset: 100 + bottomOffset: SCROLL_TO_COMMENT_BOTTOM_OFFSET }); } };