]> source.dussan.org Git - sonarqube.git/commitdiff
[NO-JIRA] Fix scroll sidebar layout
authorstanislavh <stanislav.honcharov@sonarsource.com>
Wed, 24 May 2023 08:29:31 +0000 (10:29 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 24 May 2023 20:03:14 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsAppRenderer.tsx
server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotStatusFilter.tsx

index 1e38cab7c168ed0efabe23648b0dedfd163525ba..7dbc385acad01d27676b117f56295ebbe028e2f0 100644 (file)
@@ -21,6 +21,7 @@ import { withTheme } from '@emotion/react';
 import styled from '@emotion/styled';
 import {
   DeferredSpinner,
+  LAYOUT_FOOTER_HEIGHT,
   LAYOUT_GLOBAL_NAV_HEIGHT,
   LAYOUT_PROJECT_NAV_HEIGHT,
   LargeCenteredLayout,
@@ -34,6 +35,7 @@ import A11ySkipTarget from '../../components/a11y/A11ySkipTarget';
 import Suggestions from '../../components/embed-docs-modal/Suggestions';
 import { isBranch } from '../../helpers/branch-like';
 import { translate } from '../../helpers/l10n';
+import useFollowScroll from '../../hooks/useFollowScroll';
 import { BranchLike } from '../../types/branch-like';
 import { ComponentQualifier } from '../../types/component';
 import { MetricKey } from '../../types/metrics';
@@ -105,6 +107,11 @@ export default function SecurityHotspotsAppRenderer(props: SecurityHotspotsAppRe
 
   const isProject = component.qualifier === ComponentQualifier.Project;
 
+  const { top: topScroll } = useFollowScroll();
+  const distanceFromBottom = topScroll + window.innerHeight - document.body.clientHeight;
+  const footerVisibleHeight =
+    distanceFromBottom > -LAYOUT_FOOTER_HEIGHT ? LAYOUT_FOOTER_HEIGHT + distanceFromBottom : 0;
+
   return (
     <>
       <Suggestions suggestions="security_hotspots" />
@@ -130,7 +137,22 @@ export default function SecurityHotspotsAppRenderer(props: SecurityHotspotsAppRe
                   />
                 </StyledSidebarHeader>
               )}
-              <StyledSidebarContent className="sw-p-4 it__hotspot-list">
+              <StyledSidebarContent
+                className="sw-p-4 it__hotspot-list"
+                style={{
+                  top: `${
+                    LAYOUT_GLOBAL_NAV_HEIGHT + LAYOUT_PROJECT_NAV_HEIGHT + STICKY_HEADER_HEIGHT - 2
+                  }px`,
+                  height: `calc(
+                  100vh - ${
+                    LAYOUT_GLOBAL_NAV_HEIGHT +
+                    LAYOUT_PROJECT_NAV_HEIGHT +
+                    STICKY_HEADER_HEIGHT -
+                    footerVisibleHeight
+                  }px
+                )`,
+                }}
+              >
                 <DeferredSpinner className="sw-mt-3" loading={loading}>
                   <HotspotFilterByStatus
                     filters={filters}
@@ -214,11 +236,8 @@ const StyledSidebar = withTheme(styled.section`
 `);
 
 const StyledSidebarContent = styled.div`
-  height: calc(
-    100vh - ${LAYOUT_GLOBAL_NAV_HEIGHT + LAYOUT_PROJECT_NAV_HEIGHT + STICKY_HEADER_HEIGHT}px
-  );
+  position: sticky;
   overflow-x: hidden;
-  position: relative;
   box-sizing: border-box;
   width: 100%;
 `;
index 3f19a1dac5e3152490128ef779232543f5ee6290..53aa3265324e929ce2bf1fabe52398d931820356 100644 (file)
@@ -72,7 +72,7 @@ export default function HotspotFilterByStatus(props: FilterBarProps) {
           />
         </StyledFilterWrapper>
       ) : (
-        <StyledFilterWrapper className="sw-flex sw-px-2 sw-py-4 sw-gap-2 sw-justify-between">
+        <StyledFilterWrapper className="sw-flex sw-px-2 sw-pb-4 sw-gap-2 sw-justify-between">
           <ToggleButton
             aria-label={translate('hotspot.filters.status')}
             onChange={(status: HotspotStatusFilter) => props.onChangeFilters({ status })}