Skip to content

Commit

Permalink
update scroll container selector for JumpLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvogt committed Sep 18, 2023
1 parent e532f4d commit c79dd54
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions frontend/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ErrorBoundary from '~/components/error/ErrorBoundary';
import ToastNotifications from '~/components/ToastNotifications';
import { useWatchBuildStatus } from '~/utilities/useWatchBuildStatus';
import { useUser } from '~/redux/selectors';
import { DASHBOARD_MAIN_CONTAINER_SELECTOR } from '~/utilities/const';
import { DASHBOARD_MAIN_CONTAINER_ID } from '~/utilities/const';
import useDetectUser from '~/utilities/useDetectUser';
import ProjectsContextProvider from '~/concepts/projects/ProjectsContext';
import Header from './Header';
Expand Down Expand Up @@ -96,7 +96,7 @@ const App: React.FC = () => {
sidebar={isAllowed ? <NavSidebar /> : undefined}
notificationDrawer={<AppNotificationDrawer onClose={() => setNotificationsOpen(false)} />}
isNotificationDrawerExpanded={notificationsOpen}
mainContainerId={DASHBOARD_MAIN_CONTAINER_SELECTOR}
mainContainerId={DASHBOARD_MAIN_CONTAINER_ID}
>
<ErrorBoundary>
<ProjectsContextProvider>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/GenericSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
SidebarContent,
SidebarPanel,
} from '@patternfly/react-core';
import { DASHBOARD_MAIN_CONTAINER_SELECTOR } from '~/utilities/const';
import { DASHBOARD_SCROLL_CONTAINER_SELECTOR } from '~/utilities/const';

type GenericSidebarProps = {
sections: string[];
Expand All @@ -20,7 +20,7 @@ const GenericSidebar: React.FC<GenericSidebarProps> = ({
children,
sections,
titles,
scrollableSelector = `#${DASHBOARD_MAIN_CONTAINER_SELECTOR}`,
scrollableSelector = DASHBOARD_SCROLL_CONTAINER_SELECTOR,
maxWidth,
}) => (
<Sidebar hasGutter>
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/utilities/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ export const DEFAULT_CONTEXT_DATA: ContextResourceData<never> = {
export const REPOSITORY_URL_REGEX =
/^([\w.\-_]+((?::\d+|)(?=\/[a-z0-9._-]+\/[a-z0-9._-]+))|)(?:\/|)([a-z0-9.\-_]+(?:\/[a-z0-9.\-_]+|))(?::([\w.\-_]{1,127})|)/;

export const DASHBOARD_MAIN_CONTAINER_SELECTOR = 'dashboard-page-main';
export const DASHBOARD_MAIN_CONTAINER_ID = 'dashboard-page-main';

// Quick starts drawer creates a new scroll container within its DrawerContentBody.
// Not an ideal selector but components such as JumpLinks require the use of a selector instead of a direct node reference.
export const DASHBOARD_SCROLL_CONTAINER_SELECTOR = `#${DASHBOARD_MAIN_CONTAINER_ID} > .pf-c-drawer > .pf-c-drawer__main > .pf-c-drawer__content`;
4 changes: 2 additions & 2 deletions frontend/src/utilities/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OdhApplication, OdhDocument, OdhDocumentType } from '~/types';
import { CATEGORY_ANNOTATION, DASHBOARD_MAIN_CONTAINER_SELECTOR, ODH_PRODUCT_NAME } from './const';
import { CATEGORY_ANNOTATION, DASHBOARD_MAIN_CONTAINER_ID, ODH_PRODUCT_NAME } from './const';

/**
* Feature flags are required in the config -- but upgrades can be mixed and omission of the property
Expand Down Expand Up @@ -144,7 +144,7 @@ export const isGroupEmpty = <T extends { enabled: boolean }>(groupList: Array<T>
groupList.filter((element) => element.enabled).length === 0;

export const getDashboardMainContainer = (): HTMLElement =>
document.getElementById(DASHBOARD_MAIN_CONTAINER_SELECTOR) || document.body;
document.getElementById(DASHBOARD_MAIN_CONTAINER_ID) || document.body;

export const isHTMLInputElement = (object: unknown): object is HTMLInputElement =>
(object as HTMLInputElement).value !== undefined;
Expand Down

0 comments on commit c79dd54

Please sign in to comment.