Keep the editor's section nav in view while scrolling
The nav was sticky inside a wrapper only as tall as itself, so it had nowhere to travel and scrolled away. The grid cell now sticks instead, and the mobile "Jump to" bar sits straight in the page for the same reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8186aff62f
commit
960c854611
2 changed files with 10 additions and 7 deletions
|
|
@ -80,12 +80,13 @@ function Label({ section }: { section: EditorSection }) {
|
|||
);
|
||||
}
|
||||
|
||||
/* The desktop column. Place it in the grid's first track. */
|
||||
/* The desktop column. Place it in the grid's first track, in a cell
|
||||
that is itself sticky (see EntityEdit). */
|
||||
export function SectionNav({ sections }: { sections: EditorSection[] }) {
|
||||
const active = useActiveSection(sections);
|
||||
|
||||
return (
|
||||
<nav aria-label="Sections" className="sticky top-6 hidden max-h-[calc(100vh-8rem)] overflow-y-auto lg:block">
|
||||
<nav aria-label="Sections" className="hidden max-h-[calc(100vh-8rem)] overflow-y-auto lg:block">
|
||||
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-[#4a6b72]/70">
|
||||
On this page
|
||||
</p>
|
||||
|
|
@ -119,7 +120,7 @@ export function SectionJump({ sections }: { sections: EditorSection[] }) {
|
|||
const active = useActiveSection(sections);
|
||||
|
||||
return (
|
||||
<div className="sticky top-0 z-20 -mx-6 mb-2 border-b border-[#138ba0]/15 bg-[#f6fbfc]/95 px-6 py-2 backdrop-blur lg:hidden">
|
||||
<div className="sticky top-0 z-20 -mx-6 mt-4 mb-2 border-b border-[#138ba0]/15 bg-[#f6fbfc]/95 px-6 py-2 backdrop-blur lg:hidden">
|
||||
<label className="flex items-center gap-3 text-sm text-[#4a6b72]">
|
||||
<span className="shrink-0">Jump to</span>
|
||||
<select
|
||||
|
|
|
|||
|
|
@ -364,12 +364,14 @@ export default function EntityEdit() {
|
|||
{isNew ? `New ${manifest.singular}` : heading}
|
||||
</h1>
|
||||
|
||||
<div className="mt-4">
|
||||
<SectionJump sections={sections} />
|
||||
</div>
|
||||
{/* Straight in the page, not wrapped: a sticky element only
|
||||
travels within its parent, so its parent has to be tall. */}
|
||||
<SectionJump sections={sections} />
|
||||
|
||||
<div className="lg:grid lg:grid-cols-[13rem_minmax(0,1fr)] lg:items-start lg:gap-10">
|
||||
<div className="lg:pt-6">
|
||||
{/* The grid cell is what sticks: it spans the grid, where the
|
||||
nav inside it would only span itself and have nowhere to go. */}
|
||||
<div className="lg:sticky lg:top-0 lg:pt-6">
|
||||
<SectionNav sections={sections} />
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue