Skip to content

Commit 11616a3

Browse files
David Engelhartclaude
andcommitted
lumopolis: a terminal's settings popover stays inside the window
The sidebar's Lumopolis entry and first-run hint moved the terminal list down, and a tab low in the list opened its popover with the Save button below the window's bottom edge (terminal-features test 12 failed on Linux and Windows CI). The popover now measures itself before paint and is lifted to fit, with an 8 px margin; in a window shorter than the popover it sits at the top and scrolls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 37d1b95 commit 11616a3

2 files changed

Lines changed: 210 additions & 178 deletions

File tree

‎src/renderer/src/components/TabPopover/TabPopover.tsx‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import { useState, useRef, useEffect } from 'react'
1+
import { useState, useRef, useEffect, useLayoutEffect } from 'react'
22
import { TERMINAL_THEMES, THEME_IDS, getTheme } from '../../themes/terminalThemes'
33

44
const COLOR_SWATCHES = [
55
'#22D3EE','#A5D6A7','#CE93D8','#EF9A9A','#FFE082',
66
'#80CBC4','#FFCC80','#9FA8DA','#F48FB1','#C5E1A5','#80DEEA','#B0BEC5',
77
]
88

9+
/** Space kept between the popover and the window's edges. */
10+
const POPOVER_MARGIN = 8
11+
912
const FONT_FAMILY_OPTIONS = [
1013
{ label: 'Consolas', value: 'Consolas, "Courier New", monospace' },
1114
{ label: 'JetBrains Mono', value: 'JetBrains Mono, monospace' },
@@ -31,10 +34,14 @@ export function TabPopover({ name, color, fontSize, theme, fontFamily, anchorEl,
3134
const ref = useRef<HTMLDivElement>(null)
3235
const [pos, setPos] = useState({ top: 0, left: 0 })
3336

34-
useEffect(() => {
37+
// Beside the anchor, but kept inside the window: a tab low in the sidebar would otherwise open the
38+
// popover with its Save button below the bottom edge. Measured before paint, so it never jumps.
39+
useLayoutEffect(() => {
3540
if (anchorEl) {
3641
const rect = anchorEl.getBoundingClientRect()
37-
setPos({ top: rect.top, left: rect.right + 4 })
42+
const height = (ref.current as HTMLDivElement).getBoundingClientRect().height
43+
const top = Math.max(POPOVER_MARGIN, Math.min(rect.top, window.innerHeight - height - POPOVER_MARGIN))
44+
setPos({ top, left: rect.right + 4 })
3845
}
3946
}, [anchorEl])
4047

@@ -53,7 +60,7 @@ export function TabPopover({ name, color, fontSize, theme, fontFamily, anchorEl,
5360
return (
5461
<div
5562
ref={ref}
56-
style={{ position: 'fixed', top: pos.top, left: pos.left }}
63+
style={{ position: 'fixed', top: pos.top, left: pos.left, maxHeight: `calc(100vh - ${2 * POPOVER_MARGIN}px)`, overflowY: 'auto' }}
5764
className="z-50 bg-[#252526] border border-[#3c3c3c] rounded-lg shadow-xl p-4 w-72 flex flex-col gap-3"
5865
>
5966
{/* Name */}

0 commit comments

Comments
 (0)