Skip to content

Commit 9a2d73c

Browse files
fix(editor): stop the add-block palette from being clipped by the viewport
The block palette lists 23 block types across 5 groups (~875px tall), but PopoverContent had no height cap and no scroll, so the bottom of the list was cut off by the viewport on desktop — "Separador" was unreachable and the last row of "Estructura" sat half off-screen. `popover.tsx` was the only base-ui overlay primitive missing the `max-h-(--available-height) overflow-y-auto` treatment that select, dropdown-menu and combobox already have, so fix it there: every over-tall popover now scrolls inside the space the positioner reports instead of overflowing (lesson-component-picker had the same latent bug). Also bumped the palette's legibility: item labels 11px -> 12px at full foreground contrast, group headings 10px/60% -> 11px at full muted-foreground, and the popover 340px -> 360px so the wider labels fit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MVN1bVpXJQ2CT7nv4acFRz
1 parent d2cef7c commit 9a2d73c

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

components/teacher/block-editor/add-block-menu.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ interface AddBlockMenuProps {
9191
position?: 'top' | 'inline' | 'between'
9292
}
9393

94+
// The palette is taller than the room most triggers leave on screen; PopoverContent
95+
// caps itself at `--available-height` and scrolls, so all 23 blocks stay reachable.
96+
const PALETTE_POPOVER_CLASS = 'w-[360px] p-3'
97+
9498
export function AddBlockMenu({ onSelect, position = 'inline' }: AddBlockMenuProps) {
9599
const [open, setOpen] = useState(false)
96100

@@ -111,7 +115,7 @@ export function AddBlockMenu({ onSelect, position = 'inline' }: AddBlockMenuProp
111115
<IconPlus className="h-3 w-3" />
112116
</PopoverTrigger>
113117
</div>
114-
<PopoverContent align="center" side="bottom" className="w-[340px] p-3" sideOffset={4}>
118+
<PopoverContent align="center" side="bottom" className={PALETTE_POPOVER_CLASS} sideOffset={4}>
115119
<BlockPalette onSelect={handleSelect} />
116120
</PopoverContent>
117121
</Popover>
@@ -128,7 +132,7 @@ export function AddBlockMenu({ onSelect, position = 'inline' }: AddBlockMenuProp
128132
<IconPlus className="h-4 w-4" />
129133
Añadir bloque
130134
</PopoverTrigger>
131-
<PopoverContent align="center" side="bottom" className="w-[340px] p-3" sideOffset={4}>
135+
<PopoverContent align="center" side="bottom" className={PALETTE_POPOVER_CLASS} sideOffset={4}>
132136
<BlockPalette onSelect={handleSelect} />
133137
</PopoverContent>
134138
</Popover>
@@ -144,7 +148,7 @@ export function AddBlockMenu({ onSelect, position = 'inline' }: AddBlockMenuProp
144148
>
145149
<IconPlus className="h-4 w-4" />
146150
</PopoverTrigger>
147-
<PopoverContent align="end" side="bottom" className="w-[340px] p-3" sideOffset={4}>
151+
<PopoverContent align="end" side="bottom" className={PALETTE_POPOVER_CLASS} sideOffset={4}>
148152
<BlockPalette onSelect={handleSelect} />
149153
</PopoverContent>
150154
</Popover>
@@ -159,7 +163,7 @@ function BlockPalette({ onSelect }: { onSelect: (type: BlockType) => void }) {
159163
<div className="space-y-3">
160164
{BLOCK_GROUPS.map((group) => (
161165
<div key={group.label}>
162-
<p className="mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/60">
166+
<p className="mb-1.5 px-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">
163167
{group.label}
164168
</p>
165169
<div className="grid grid-cols-3 gap-1.5">
@@ -181,7 +185,7 @@ function BlockPalette({ onSelect }: { onSelect: (type: BlockType) => void }) {
181185
<div className={cn('flex h-8 w-8 items-center justify-center rounded-md', iconData.bg)}>
182186
<Icon className={cn('h-4 w-4', iconData.color)} />
183187
</div>
184-
<span className="text-[11px] font-medium leading-tight text-muted-foreground group-hover:text-foreground">
188+
<span className="text-xs font-medium leading-tight text-foreground/80 group-hover:text-foreground">
185189
{meta?.label || type}
186190
</span>
187191
</button>

components/ui/popover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function PopoverContent({
3737
<PopoverPrimitive.Popup
3838
data-slot="popover-content"
3939
className={cn(
40-
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
40+
"z-50 flex max-h-(--available-height) w-72 origin-(--transform-origin) flex-col gap-4 overflow-y-auto overscroll-contain rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
4141
className
4242
)}
4343
{...props}

0 commit comments

Comments
 (0)