Skip to content

Commit dff8249

Browse files
jpinsonneauopenshift-cherrypick-robot
authored andcommitted
fix pf6 expand / collapse
1 parent ea98aaa commit dff8249

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

web/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const App: React.FunctionComponent = () => {
108108
aria-label="Global navigation"
109109
isSidebarOpen={isSidebarOpen}
110110
onSidebarToggle={onSidebarToggle}
111-
id="vertical-nav-toggle"
111+
id="nav-toggle"
112112
>
113113
<BarsIcon />
114114
</PageToggleButton>

web/src/components/netflow-traffic.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,10 +735,29 @@ export const NetflowTraffic: React.FC<NetflowTrafficProps> = ({
735735

736736
//update page on full screen change
737737
React.useEffect(() => {
738+
// collapse pf6 navigation for compatibility
739+
if (model.isFullScreen && document.getElementsByClassName('pf-v6-c-page__sidebar pf-m-expanded').length) {
740+
document.getElementById('nav-toggle')?.click();
741+
}
742+
738743
const header = document.getElementById('page-main-header');
744+
const headersV5Compat = document.getElementsByClassName('pf-v5-c-masthead');
745+
const headersV6Compat = document.getElementsByClassName('pf-v6-c-masthead');
746+
739747
const sideBar = document.getElementById('page-sidebar');
748+
const sideBarsV5Compat = document.getElementsByClassName('pf-v5-c-page__sidebar');
749+
const sideBarsV6Compat = document.getElementsByClassName('pf-v6-c-page__sidebar');
750+
740751
const notification = document.getElementsByClassName('co-global-notifications');
741-
[header, sideBar, ...notification].forEach(e => {
752+
[
753+
header,
754+
...headersV5Compat,
755+
...headersV6Compat,
756+
sideBar,
757+
...sideBarsV5Compat,
758+
...sideBarsV6Compat,
759+
...notification
760+
].forEach(e => {
742761
if (model.isFullScreen) {
743762
e?.classList.add('hidden');
744763
} else {

web/src/utils/theme-hook.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ import * as React from 'react';
22

33
export function useTheme(): boolean {
44
const [isDarkTheme, setDarkTheme] = React.useState<boolean>(
5-
document.documentElement.classList.contains('pf-v5-theme-dark')
5+
document.documentElement.classList.contains('pf-v5-theme-dark') ||
6+
document.documentElement.classList.contains('pf-v6-theme-dark')
67
);
78
const observer = new MutationObserver((mutations: MutationRecord[]) => {
89
mutations.forEach((mutation: MutationRecord) => {
910
if (mutation.attributeName === 'class') {
10-
setDarkTheme((mutation.target as HTMLElement).classList.contains('pf-v5-theme-dark'));
11+
setDarkTheme(
12+
(mutation.target as HTMLElement).classList.contains('pf-v5-theme-dark') ||
13+
(mutation.target as HTMLElement).classList.contains('pf-v6-theme-dark')
14+
);
1115
}
1216
});
1317
});

0 commit comments

Comments
 (0)