- Notifications
You must be signed in to change notification settings - Fork928
fix(site): fix build logs scrolling on safari#14884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from3 commits
1adeb36
c81a42b
170bc1c
bbb93bb
7a5f53e
8912122
01e66ed
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -24,7 +24,14 @@ import { | ||
WorkspaceBuildDataSkeleton, | ||
} from "modules/workspaces/WorkspaceBuildData/WorkspaceBuildData"; | ||
import { WorkspaceBuildLogs } from "modules/workspaces/WorkspaceBuildLogs/WorkspaceBuildLogs"; | ||
import { | ||
type CSSProperties, | ||
type FC, | ||
type HTMLProps, | ||
useLayoutEffect, | ||
useRef, | ||
useState, | ||
} from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { displayWorkspaceBuildDuration } from "utils/workspace"; | ||
import { Sidebar, SidebarCaption, SidebarItem } from "./Sidebar"; | ||
@@ -144,7 +151,7 @@ export const WorkspaceBuildPageView: FC<WorkspaceBuildPageViewProps> = ({ | ||
))} | ||
</Sidebar> | ||
<ScrollArea> | ||
<Tabs active={tabState.value}> | ||
<TabsList> | ||
<TabLink to={`?${LOGS_TAB_KEY}=build`} value="build"> | ||
@@ -197,12 +204,47 @@ export const WorkspaceBuildPageView: FC<WorkspaceBuildPageViewProps> = ({ | ||
agent={selectedAgent!} | ||
/> | ||
)} | ||
</ScrollArea> | ||
</div> | ||
</DashboardFullPage> | ||
); | ||
}; | ||
const ScrollArea: FC<HTMLProps<HTMLDivElement>> = () => { | ||
// TODO: Use only CSS to set the height of the content. | ||
// Note: On Safari, when content is rendered inside a flex container and needs | ||
// to scroll, the parent container must have a height set. Achieving this may | ||
// require significant refactoring of the layout components where we currently | ||
// use height and min-height set to 100%. | ||
// Issue: https://github.com/coder/coder/issues/9687 | ||
// Reference: https://stackoverflow.com/questions/43381836/height100-works-in-chrome-but-not-in-safari | ||
const contentRef = useRef<HTMLDivElement>(null); | ||
const [height, setHeight] = useState<CSSProperties["width"]>("100%"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Tiny thing, but could we set the type to be based on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. lol yes, idk why I used width 🤦 | ||
useLayoutEffect(() => { | ||
const contentEl = contentRef.current; | ||
if (!contentEl) { | ||
return; | ||
} | ||
const resizeObserver = new ResizeObserver(() => { | ||
const parentEl = contentEl.parentElement; | ||
if (!parentEl) { | ||
return; | ||
} | ||
setHeight(parentEl.clientHeight); | ||
}); | ||
resizeObserver.observe(document.body); | ||
return () => { | ||
resizeObserver.disconnect(); | ||
}; | ||
}, []); | ||
return ( | ||
<div ref={contentRef} css={{ height, overflowY: "auto", width: "100%" }} /> | ||
); | ||
}; | ||
const BuildLogsContent: FC<{ logs?: ProvisionerJobLog[] }> = ({ logs }) => { | ||
if (!logs) { | ||
return <Loader />; | ||
Uh oh!
There was an error while loading.Please reload this page.