Skip to content

Commit 13ecac9

Browse files
committed
Replace custom CSS with PatternFly Sidebar on User Preferences page
Also, apply an override z-index to handle upstream PatternFly bug Assisted by Claude code
1 parent 52099b4 commit 13ecac9

4 files changed

Lines changed: 26 additions & 64 deletions

File tree

frontend/packages/console-app/src/components/user-preferences/UserPreferenceForm.scss

Lines changed: 0 additions & 13 deletions
This file was deleted.

frontend/packages/console-app/src/components/user-preferences/UserPreferenceForm.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@ import { Form } from '@patternfly/react-core';
33
import type { ResolvedUserPreferenceItem } from './types';
44
import UserPreferenceField from './UserPreferenceField';
55

6-
import './UserPreferenceForm.scss';
7-
86
type UserPreferenceFormProps = { items: ResolvedUserPreferenceItem[] };
97

108
const UserPreferenceForm: FC<UserPreferenceFormProps> = ({ items }) =>
119
items && items.length > 0 ? (
12-
<Form
13-
onSubmit={(event) => event.preventDefault()}
14-
className="co-user-preference__form"
15-
role="form"
16-
>
10+
<Form onSubmit={(event) => event.preventDefault()} role="form">
1711
{items.map((item) => (
1812
<UserPreferenceField key={item.id} item={item} />
1913
))}
Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,6 @@
1-
.co-user-preference-page {
2-
display: flex;
3-
min-height: 100%;
4-
overflow-y: auto;
5-
flex-direction: column;
6-
}
7-
8-
.co-user-preference-page-content {
9-
display: flex;
10-
flex-direction: row;
11-
background-color: var(--pf-t--global--background--color--primary--default);
12-
min-height: 100%;
13-
&__tabs {
14-
@media (min-width: 769px) {
15-
max-width: 100%;
16-
}
17-
18-
@media (min-width: 992px) {
19-
min-width: 220px;
20-
}
21-
22-
@media (min-width: 1200px) {
23-
max-width: 220px;
24-
}
25-
}
26-
&__tab-content {
27-
margin: var(--pf-t--global--spacer--lg);
28-
max-width: 100%;
29-
}
30-
31-
//workaround for patternfly bug which causes the buttons to show even when isVertical prop is true
32-
.pf-v6-c-tabs__scroll-button {
33-
display: none;
34-
}
1+
// Workaround: SidebarPanel and MenuToggle both use --pf-t--global--z-index--xs,
2+
// so menu-toggles render above the sticky panel when content scrolls at mobile width.
3+
// TODO: Remove when fixed upstream in PatternFly. See: https://github.com/patternfly/patternfly/issues/8323
4+
.co-user-preferences__sidebar-panel {
5+
--pf-v6-c-sidebar__panel--ZIndex: var(--pf-t--global--z-index--sm);
356
}

frontend/packages/console-app/src/components/user-preferences/UserPreferencePage.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import { useMemo, useState, useEffect, createRef } from 'react';
22
import type { FC, ReactElement, JSXElementConstructor, MouseEvent } from 'react';
33
import type { TabProps, TabContentProps } from '@patternfly/react-core';
4-
import { Tabs, Tab, TabTitleText, TabContent, PageSection } from '@patternfly/react-core';
4+
import {
5+
Tabs,
6+
Tab,
7+
TabTitleText,
8+
TabContent,
9+
PageSection,
10+
Sidebar,
11+
SidebarContent,
12+
SidebarPanel,
13+
} from '@patternfly/react-core';
514
import { useTranslation } from 'react-i18next';
615
import { useParams, useNavigate } from 'react-router';
716
import {
@@ -19,14 +28,14 @@ import { useQueryParams } from '@console/shared/src/hooks/useQueryParams';
1928
import { orderExtensionBasedOnInsertBeforeAndAfter } from '@console/shared/src/utils/order-extensions';
2029
import { isModifiedEvent } from '@console/shared/src/utils/utils';
2130
import { USER_PREFERENCES_BASE_URL } from './const';
31+
import './UserPreferencePage.scss';
2232
import type {
2333
UserPreferenceTabGroup,
2434
ResolvedUserPreferenceItem,
2535
ResolvedUserPreferenceGroup,
2636
} from './types';
2737
import UserPreferenceForm from './UserPreferenceForm';
2838
import { getUserPreferenceGroups } from './utils/getUserPreferenceGroups';
29-
import './UserPreferencePage.scss';
3039

3140
const UserPreferencePage: FC = () => {
3241
// resources and calls to hooks
@@ -78,6 +87,7 @@ const UserPreferencePage: FC = () => {
7887
);
7988
acc[1].push(
8089
<TabContent
90+
className="pf-v6-u-w-75-on-lg pf-v6-u-w-50-on-xl"
8191
key={id}
8292
eventKey={id}
8393
id={id}
@@ -117,7 +127,7 @@ const UserPreferencePage: FC = () => {
117127
};
118128
const activeTab = sortedUserPreferenceGroups.find((group) => group.id === activeTabId)?.label;
119129
return (
120-
<div className="co-user-preference-page">
130+
<>
121131
<DocumentTitle>
122132
{activeTab
123133
? t('console-app~User Preferences {{activeTab}}', { activeTab })
@@ -131,8 +141,8 @@ const UserPreferencePage: FC = () => {
131141
/>
132142
<PageSection>
133143
{userPreferenceItemResolved ? (
134-
<div className="co-user-preference-page-content">
135-
<div className="co-user-preference-page-content__tabs">
144+
<Sidebar hasGutter>
145+
<SidebarPanel variant="sticky" className="co-user-preferences__sidebar-panel">
136146
<Tabs
137147
activeKey={activeTabId}
138148
onSelect={handleTabClick}
@@ -142,17 +152,17 @@ const UserPreferencePage: FC = () => {
142152
>
143153
{userPreferenceTabs}
144154
</Tabs>
145-
</div>
146-
<div className="co-user-preference-page-content__tab-content">
155+
</SidebarPanel>
156+
<SidebarContent>
147157
{userPreferenceTabContents}
148158
{spotlight && spotlightElement && <Spotlight selector={spotlight} interactive />}
149-
</div>
150-
</div>
159+
</SidebarContent>
160+
</Sidebar>
151161
) : (
152162
<LoadingBox />
153163
)}
154164
</PageSection>
155-
</div>
165+
</>
156166
);
157167
};
158168

0 commit comments

Comments
 (0)