Skip to content

Commit 2ab3d10

Browse files
fix(site): enable sticky positioning inside #main-content (#26907)
ref DEVEX-567 Fixes a bug I noticed where #26881 claims to have made the template builder's `SelectionSummary` sidebar sticky-positioned, but the sidebar position wasn't actually sticky in practice: ## template builder's `SelectionSummary` (top right) ### before https://github.com/user-attachments/assets/1e9360b5-4b0e-45b4-a859-f8edab51add7 ### after https://github.com/user-attachments/assets/3cee75e9-9813-401e-9922-d2563185f8f5 --- Why I removed `overflow-y-auto` from `#main-content`: >`position: sticky` resolves against the nearest ancestor scroll container — any ancestor whose overflow is not visible. `#main-content` had `overflow-y-auto`, so it _was_ that container for the sidebar. But because the layout wrapper is `min-h-screen`, `<main>` grows to fit its content and never actually scrolls — the window scrolls. So the sidebar was pinning relative to a container that never moves → no effect. That was necessary for the main goal of this PR, which was to fix sticky positioning for the template builder's `SelectionSummary` sidebar. However, removing that style from `#main-content` affected 2 other sticky-positioned elements within the site: >Two other pages have sticky elements that, like our sidebar, were resolving against the non-scrolling `<main>` and were therefore effectively inert: >- CreateWorkspacePageView.tsx:397 — `sticky top-5` side panel >- modules/templates/TemplateFiles/TemplateFiles.tsx:64 — `sticky top-8` file tree ^Like `SelectionSummary`, these 2 elements hadn't been behaving with sticky positioning as expected; they would just scroll away past the top of the screen. For all 3 of these sticky elements, since their `top` is now relative to the window instead of `#main-content`, they have to be positioned farther downward so that they don't get covered by the navbar. ## `TemplateFiles`' `TemplateFileTree` (top left) ### before https://github.com/user-attachments/assets/ee79ea36-1a47-4b1b-86ef-c65b493ea455 ### after https://github.com/user-attachments/assets/a1b0a949-b5e3-4434-acaa-ab24e82b1669 ## `CreateWorkspacePageView`'s "Go back" button (top left) ### before https://github.com/user-attachments/assets/00b076f6-8e55-4a96-8b92-d33d92c85334 ### after https://github.com/user-attachments/assets/10ae05e1-3112-4dfc-84b4-2c44fee23e06 co-authored with Claude Code --------- Co-authored-by: Jeremy Ruppel <jeremyruppel@users.noreply.github.com>
1 parent 60254c8 commit 2ab3d10

6 files changed

Lines changed: 8 additions & 7 deletions

File tree

site/src/components/Form/Form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const FormSection: FC<FormSectionProps> = ({
9999
>
100100
<div
101101
className={cn(
102-
"w-full shrink-0 top-6",
102+
"w-full shrink-0 top-24",
103103
direction === "horizontal" && "lg:sticky lg:max-w-[312px]",
104104
classes.sectionInfo,
105105
)}

site/src/modules/dashboard/DashboardLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const DashboardLayout: FC = () => {
4343
id="main-content"
4444
tabIndex={-1}
4545
className={cn(
46-
"relative flex flex-col flex-1 min-h-0 overflow-y-auto",
46+
"relative flex flex-col flex-1 min-h-0",
4747
"focus:outline-none",
4848
)}
4949
>

site/src/modules/templates/TemplateFiles/TemplateFiles.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export const TemplateFiles: FC<TemplateFilesProps> = ({
6161
return (
6262
<div>
6363
<div className="flex items-start gap-8">
64-
<div className="sticky top-8 w-[240px] shrink-0 overflow-auto rounded-lg border border-solid border-surface-quaternary py-1">
64+
{/* top-28 (112px) is a sum of nav height (72px) and TemplateLayout's LinkTabs' mb-10 (40px) */}
65+
<div className="sticky top-28 w-[240px] shrink-0 overflow-auto rounded-lg border border-solid border-surface-quaternary py-1">
6566
<TemplateFileTree
6667
fileTree={fileTree}
6768
onSelect={(path: string) => {

site/src/pages/CreateTemplateGalleryPage/StarterTemplates.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const StarterTemplates: FC<StarterTemplatesProps> = ({
6565
return (
6666
<div className="flex flex-row gap-8 items-start">
6767
{starterTemplatesByTag && tags && (
68-
<div className="flex flex-col gap-4 w-[202px] shrink-0 sticky">
68+
<div className="flex flex-col gap-4 w-[202px] shrink-0 sticky top-[88px]">
6969
<h2 className="m-0 text-base font-normal text-content-primary">
7070
Choose a starter template
7171
</h2>

site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
398398
<button
399399
onClick={onCancel}
400400
type="button"
401-
className="flex items-center gap-2 bg-transparent border-none text-content-secondary hover:text-content-primary translate-y-12"
401+
className="flex items-center gap-2 bg-transparent border-none text-content-secondary hover:text-content-primary translate-y-[68px]"
402402
>
403403
<ArrowLeftIcon size={20} />
404404
Go back

site/src/pages/TemplateBuilder/TemplateBuilderPageView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ export const TemplateBuilderPageView: FC<TemplateBuilderPageViewProps> = ({
182182
{currentStep.id === "base-infra" && <TemplateAlternatives />}
183183
</div>
184184

185-
{/* Sidebar */}
186-
<div className="w-64 shrink-0 hidden md:block sticky top-0 self-start">
185+
{/* Sidebar (top position is 72px so that it can sit below nav) */}
186+
<div className="w-64 shrink-0 hidden md:block sticky top-[72px] self-start">
187187
<SelectionSummary
188188
currentStep={currentStep.group}
189189
selectedTemplate={

0 commit comments

Comments
 (0)