]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19068 Fix scrolling issue
authorJeremy Davis <jeremy.davis@sonarsource.com>
Mon, 28 Aug 2023 15:00:55 +0000 (17:00 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 29 Aug 2023 20:03:08 +0000 (20:03 +0000)
server/sonar-web/design-system/src/components/TopBar.tsx
server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
server/sonar-web/src/main/js/app/components/GlobalContainer.tsx
server/sonar-web/src/main/js/app/components/SystemAnnouncement.css
server/sonar-web/src/main/js/app/components/indexation/IndexationNotification.css
server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx
server/sonar-web/src/main/js/app/components/update-notification/UpdateNotification.css

index de789f4a22859eb2ea55e50a4387ddd86d433faf..36c2c6f024f896988284a4c217fd46d9e8d5b6ac 100644 (file)
@@ -23,7 +23,6 @@ import { LAYOUT_VIEWPORT_MIN_WIDTH } from '../helpers';
 import { themeColor, themeContrast, themeShadow } from '../helpers/theme';
 
 export const TopBar = styled.nav`
-  ${tw`sw-z-top-navbar`}
   ${tw`sw-px-6 sw-pt-4`}
   ${tw`sw-box-border`};
   ${tw`sw-w-full`};
index bba0da8a47168ebb41dacbf3f81fec025c062139..25e731d7e2e1419dc5dbf01451baf67b38001e7f 100644 (file)
@@ -20,6 +20,7 @@
 
 import { differenceBy } from 'lodash';
 import * as React from 'react';
+import { createPortal } from 'react-dom';
 import { Helmet } from 'react-helmet-async';
 import { Outlet } from 'react-router-dom';
 import { validateProjectAlmBinding } from '../../api/alm-settings';
@@ -63,10 +64,13 @@ export class ComponentContainer extends React.PureComponent<Props, State> {
   watchStatusTimer?: number;
   mounted = false;
   state: State = { isPending: false, loading: true };
+  portalAnchor: Element | null = null;
 
   componentDidMount() {
     this.mounted = true;
     this.fetchComponent();
+
+    this.portalAnchor = document.querySelector('#component-nav-portal');
   }
 
   componentDidUpdate(prevProps: Props) {
@@ -335,14 +339,18 @@ export class ComponentContainer extends React.PureComponent<Props, State> {
         {component &&
           !([ComponentQualifier.File, ComponentQualifier.TestFile] as string[]).includes(
             component.qualifier
-          ) && (
+          ) &&
+          this.portalAnchor &&
+          /* Use a portal to fix positioning until we can fully review the layout */
+          createPortal(
             <ComponentNav
               component={component}
               currentTask={currentTask}
               isInProgress={isInProgress}
               isPending={isPending}
               projectBindingErrors={projectBindingErrors}
-            />
+            />,
+            this.portalAnchor
           )}
 
         {loading ? (
index 5fba3cf935c5230b470e8dd14d517336be1f152d..9ac12eddab336f31704dc5f1d969981c9fb543cd 100644 (file)
@@ -84,6 +84,10 @@ export default function GlobalContainer() {
                             <NCDAutoUpdateMessage />
                             <UpdateNotification dismissable />
                             <GlobalNav location={location} />
+                            {/* The following is the portal anchor point for the component nav
+                             * See ComponentContainer.tsx
+                             */}
+                            <div id="component-nav-portal" />
                           </div>
                           <Outlet />
                         </MetricsContextProvider>
index 38967552052fc42a51aa82befd783081c65e2b26..f23bb366800c9f4271730709cb18de54c8fccfcd 100644 (file)
@@ -22,7 +22,6 @@
 }
 
 .system-announcement-banner {
-  position: fixed;
   width: 100%;
   z-index: var(--globalBannerZIndex);
 }
index a460179eff470a94290bc4fe31744fb64c148132..80315d8ad6ff3586199c25429a54fddc9987fa1c 100644 (file)
@@ -22,7 +22,6 @@
 }
 
 .indexation-notification-banner {
-  position: fixed;
   width: 100%;
   z-index: var(--globalBannerZIndex);
   margin-bottom: 0 !important;
index e25d86d2a97e1f13874272fa6f885f29a80ca07b..151f5c72ab0c4d21e96b0f6462b9230ba8ca6046 100644 (file)
@@ -19,7 +19,6 @@
  */
 import { TopBar } from 'design-system';
 import * as React from 'react';
-import ScreenPositionHelper from '../../../../components/common/ScreenPositionHelper';
 import NCDAutoUpdateMessage from '../../../../components/new-code-definition/NCDAutoUpdateMessage';
 import { translate } from '../../../../helpers/l10n';
 import { ProjectAlmBindingConfigurationErrors } from '../../../../types/alm-settings';
@@ -57,36 +56,24 @@ export default function ComponentNav(props: ComponentNavProps) {
     }
   }, [component, component.key]);
 
-  let prDecoNotifComponent: JSX.Element;
-  if (projectBindingErrors !== undefined) {
-    prDecoNotifComponent = <ComponentNavProjectBindingErrorNotif component={component} />;
-  }
-
   return (
-    <ScreenPositionHelper className="sw-inline">
-      {({ top }) => (
-        <>
-          <TopBar
-            className="sw-sticky"
-            id="context-navigation"
-            aria-label={translate('qualifier', component.qualifier)}
-            style={{ top: `${top}px` }}
-          >
-            <div className="sw-min-h-10 sw-flex sw-justify-between">
-              <Header component={component} />
-              <HeaderMeta
-                component={component}
-                currentTask={currentTask}
-                isInProgress={isInProgress}
-                isPending={isPending}
-              />
-            </div>
-            <Menu component={component} isInProgress={isInProgress} isPending={isPending} />
-          </TopBar>
-          <NCDAutoUpdateMessage component={component} />
-          {prDecoNotifComponent}
-        </>
+    <>
+      <TopBar id="context-navigation" aria-label={translate('qualifier', component.qualifier)}>
+        <div className="sw-min-h-10 sw-flex sw-justify-between">
+          <Header component={component} />
+          <HeaderMeta
+            component={component}
+            currentTask={currentTask}
+            isInProgress={isInProgress}
+            isPending={isPending}
+          />
+        </div>
+        <Menu component={component} isInProgress={isInProgress} isPending={isPending} />
+      </TopBar>
+      <NCDAutoUpdateMessage component={component} />
+      {projectBindingErrors !== undefined && (
+        <ComponentNavProjectBindingErrorNotif component={component} />
       )}
-    </ScreenPositionHelper>
+    </>
   );
 }
index 8ed41dd50b8ba4e69cba2b867a2cf56ce0b5e7d4..da5494f86c7cf376e46e40782921181186038efe 100644 (file)
@@ -23,7 +23,6 @@
 
 .promote-update-notification .dismissable-alert-banner {
   margin-bottom: 0 !important;
-  position: fixed;
   width: 100%;
   z-index: var(--globalBannerZIndex);
 }