Files
opencode-manager/frontend/src/lib/settingsScroll.ts
T
Chris Scott 2a4fa956b4 refactor(settings): redesign OpenCode settings with shared collapsible sections
- Replace bordered cards with compact flat rows and maintenance sections
- Add shared SettingsDisclosure for config, maintenance, and sandbox sections
- Auto-scroll expanded sections into view when outside the scrollport
- Make agent file editor and agent form full-height and keyboard-aware on mobile
2026-09-19 10:14:34 -04:00

32 lines
961 B
TypeScript

interface RectLike {
top: number
bottom: number
}
export function isSectionFullyVisible(section: RectLike, scroller: RectLike): boolean {
return section.top >= scroller.top && section.bottom <= scroller.bottom
}
function findScrollContainer(element: HTMLElement): HTMLElement | null {
let node = element.parentElement
while (node) {
const { overflowY } = getComputedStyle(node)
if ((overflowY === 'auto' || overflowY === 'scroll') && node.scrollHeight > node.clientHeight) {
return node
}
node = node.parentElement
}
return null
}
export function scrollSectionIntoView(header: HTMLElement | null) {
if (!header) return
const section = header.parentElement
if (!section) return
const scroller = findScrollContainer(section)
if (scroller && isSectionFullyVisible(section.getBoundingClientRect(), scroller.getBoundingClientRect())) {
return
}
header.scrollIntoView({ behavior: 'smooth', block: 'start' })
}