Skip to content

Commit b60185b

Browse files
committed
fix: inner scrolling on tabs
Signed-off-by: Nick Mitchell <[email protected]>
1 parent b2e19cf commit b60185b

File tree

5 files changed

+79
-45
lines changed

5 files changed

+79
-45
lines changed

pdl-live-react/src/Page.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import {
66
PageSection,
77
} from "@patternfly/react-core"
88

9-
import Masthead from "./Masthead"
109
import Sidebar from "./Sidebar"
10+
import Masthead from "./Masthead"
11+
import ViewerTabs from "./ViewerTabs"
1112
import DrawerContent from "./DrawerContent"
1213

1314
import DrawerContext from "./DrawerContentContext"
1415
import DarkModeContext, { getDarkModeUserSetting } from "./DarkModeContext"
1516

17+
const notFilled = { isFilled: false }
18+
1619
type Props = PropsWithChildren<{
1720
breadcrumb1?: string
1821
breadcrumb2?: string
@@ -49,6 +52,9 @@ export default function PDLPage({ breadcrumb1, breadcrumb2, children }: Props) {
4952
<Masthead setDarkMode={setDarkMode} />
5053
</DarkModeContext.Provider>
5154
}
55+
horizontalSubnav={<ViewerTabs />}
56+
groupProps={notFilled /* so breadcrumbs aren't filled */}
57+
isBreadcrumbGrouped
5258
breadcrumb={
5359
breadcrumb1 && (
5460
<Breadcrumb>
@@ -60,7 +66,7 @@ export default function PDLPage({ breadcrumb1, breadcrumb2, children }: Props) {
6066
>
6167
<PageSection
6268
isFilled
63-
hasOverflowScroll={false}
69+
hasOverflowScroll
6470
aria-label="PDL Viewer main section"
6571
>
6672
<DrawerContext.Provider value={setDrawerContent}>

pdl-live-react/src/Viewer.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@
88
.pdl-mono {
99
font-family: var(--pf-t--global--font--family--mono);
1010
}
11+
12+
.pf-v6-c-page__main-body {
13+
flex: 1;
14+
15+
& > section[data-fill-height] {
16+
height: 100%;
17+
}
18+
}
19+
.pdl-viewer-tab:not([hidden]) {
20+
height: 100%;
21+
overflow: auto;
22+
}

pdl-live-react/src/Viewer.tsx

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { useLocation } from "react-router"
22
import { useContext, useMemo } from "react"
33

4-
import { Tabs, Tab, TabTitleText } from "@patternfly/react-core"
5-
64
import Code from "./view/Code"
75
import Transcript from "./view/transcript/Transcript"
86
import DarkModeContext from "./DarkModeContext"
@@ -14,7 +12,7 @@ import "./Viewer.css"
1412
/** This is the main view component */
1513
export default function Viewer({ value }: { value: string }) {
1614
// We will use this to find the current active tab (below)
17-
let { hash: activeTab } = useLocation()
15+
const { hash: activeTab } = useLocation()
1816

1917
// DarkMode state
2018
const darkMode = useContext(DarkModeContext)
@@ -28,45 +26,17 @@ export default function Viewer({ value }: { value: string }) {
2826
return "Invalid trace content"
2927
}
3028

31-
// Note: please keep eventKey===href
32-
const tabs = [
33-
<Tab
34-
key="#transcript"
35-
href="#transcript"
36-
eventKey="#transcript"
37-
className="pdl-viewer-tab"
38-
title={<TabTitleText>Transcript</TabTitleText>}
39-
>
40-
<Transcript data={data} />
41-
</Tab>,
42-
<Tab
43-
key="#source"
44-
href="#source"
45-
eventKey="#source"
46-
className="pdl-viewer-tab"
47-
title={<TabTitleText>Source</TabTitleText>}
48-
>
49-
<Code block={data} darkMode={darkMode} limitHeight={false} />
50-
</Tab>,
51-
<Tab
52-
key="#raw"
53-
href="#raw"
54-
eventKey="#raw"
55-
className="pdl-viewer-tab"
56-
title={<TabTitleText>Raw Trace</TabTitleText>}
57-
>
58-
<Code block={data} darkMode={darkMode} limitHeight={false} raw />
59-
</Tab>,
60-
]
61-
62-
if (!tabs.find((tab) => tab.props.href === activeTab)) {
63-
// User provided bogus hash, default to first tab
64-
activeTab = tabs[0].props.href
65-
}
66-
6729
return (
68-
<Tabs activeKey={activeTab} component="nav">
69-
{tabs}
70-
</Tabs>
30+
<>
31+
<section hidden={activeTab !== "#source"}>
32+
<Code block={data} darkMode={darkMode} limitHeight={false} />
33+
</section>
34+
<section hidden={activeTab !== "raw"}>
35+
<Code block={data} darkMode={darkMode} limitHeight={false} raw />
36+
</section>
37+
<section hidden={activeTab === "#source" || activeTab === "#raw"}>
38+
<Transcript data={data} />
39+
</section>
40+
</>
7141
)
7242
}

pdl-live-react/src/ViewerTabs.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { useLocation } from "react-router"
2+
import { Tabs, Tab, TabTitleText } from "@patternfly/react-core"
3+
4+
import "./Viewer.css"
5+
6+
/** This is the main view component */
7+
export default function Viewer() {
8+
// We will use this to find the current active tab (below)
9+
let { hash: activeTab } = useLocation()
10+
11+
// Note: please keep eventKey===href
12+
const tabs = [
13+
<Tab
14+
key="#transcript"
15+
href="#transcript"
16+
eventKey="#transcript"
17+
className="pdl-viewer-tab"
18+
title={<TabTitleText>Transcript</TabTitleText>}
19+
/>,
20+
<Tab
21+
key="#source"
22+
href="#source"
23+
eventKey="#source"
24+
className="pdl-viewer-tab"
25+
title={<TabTitleText>Source</TabTitleText>}
26+
/>,
27+
<Tab
28+
key="#raw"
29+
href="#raw"
30+
eventKey="#raw"
31+
className="pdl-viewer-tab"
32+
title={<TabTitleText>Raw Trace</TabTitleText>}
33+
/>,
34+
]
35+
36+
if (!tabs.find((tab) => tab.props.href === activeTab)) {
37+
// User provided bogus hash, default to first tab
38+
activeTab = tabs[0].props.href
39+
}
40+
41+
return (
42+
<Tabs activeKey={activeTab} component="nav">
43+
{tabs}
44+
</Tabs>
45+
)
46+
}

pdl-live-react/src/view/transcript/Transcript.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.pdl-transcript-item {
22
&:first-child {
3-
margin-top: 1em;
3+
/* margin-top: 1em; */
44
}
55
}
66

0 commit comments

Comments
 (0)