11import { CollapsibleSectionHeader } from "../ui/collapsible-section-header" ;
22import { useSortable } from "@dnd-kit/sortable" ;
33import { CSS } from "@dnd-kit/utilities" ;
4- import { type ReactNode } from "react" ;
4+ import { type ReactNode , useLayoutEffect } from "react" ;
55import { cn } from "~/lib/utils" ;
66import {
77 animateSidebarLayoutChanges ,
@@ -15,13 +15,20 @@ function SortableSidebarMarker(props: {
1515 marker : SidebarListMarker ;
1616 className ?: string ;
1717 children ?: ReactNode ;
18+ revealOverflow ?: boolean ;
1819 "data-testid" ?: string ;
1920} ) {
20- const { setNodeRef, transform, transition } = useSortable ( {
21+ const { node , setNodeRef, transform, transition } = useSortable ( {
2122 id : sidebarMarkerId ( props . marker ) ,
2223 disabled : SIDEBAR_SORTABLE_DRAG_DISABLED ,
2324 animateLayoutChanges : animateSidebarLayoutChanges ,
2425 } ) ;
26+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- keeps the projected drop box inside the scroll viewport as drag transforms move it
27+ useLayoutEffect ( ( ) => {
28+ if ( props . revealOverflow && transform ?. y !== undefined ) {
29+ node . current ?. firstElementChild ?. scrollIntoView ( { block : "nearest" , inline : "nearest" } ) ;
30+ }
31+ } , [ node , props . revealOverflow , transform ?. y ] ) ;
2532 return (
2633 < li
2734 ref = { setNodeRef }
@@ -50,6 +57,7 @@ export function SidebarSectionPlaceholder(props: {
5057 marker = { props . marker }
5158 data-testid = { `sidebar-${ props . marker } ` }
5259 className = "relative mx-0.5 -mb-px h-0"
60+ revealOverflow = { props . marker === "settled-placeholder" && props . showHint }
5361 >
5462 { props . showHint ? (
5563 < div
0 commit comments