TypeScript
fix(web): keep settled drop hint inside the sidebar viewport (#26736)
Yash Singh221610f0caa9
diff --git a/apps/web/src/components/sidebar/SidebarListMarkers.tsx b/apps/web/src/components/sidebar/SidebarListMarkers.tsxindex 30a6776837e..3a78876fa58 100644--- a/apps/web/src/components/sidebar/SidebarListMarkers.tsx+++ b/apps/web/src/components/sidebar/SidebarListMarkers.tsx@@ -1,7 +1,7 @@import { CollapsibleSectionHeader } from "../ui/collapsible-section-header";import { useSortable } from "@dnd-kit/sortable";import { CSS } from "@dnd-kit/utilities";-import { type ReactNode } from "react";+import { type ReactNode, useLayoutEffect } from "react";import { cn } from "~/lib/utils";import {animateSidebarLayoutChanges,@@ -15,13 +15,20 @@ function SortableSidebarMarker(props: {marker: SidebarListMarker;className?: string;children?: ReactNode;+ revealOverflow?: boolean;"data-testid"?: string;}) {- const { setNodeRef, transform, transition } = useSortable({+ const { node, setNodeRef, transform, transition } = useSortable({id: sidebarMarkerId(props.marker),disabled: SIDEBAR_SORTABLE_DRAG_DISABLED,animateLayoutChanges: animateSidebarLayoutChanges,});+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- keeps the projected drop box inside the scroll viewport as drag transforms move it+ useLayoutEffect(() => {+ if (props.revealOverflow && transform?.y !== undefined) {+ node.current?.firstElementChild?.scrollIntoView({ block: "nearest", inline: "nearest" });+ }+ }, [node, props.revealOverflow, transform?.y]);return (<liref={setNodeRef}@@ -50,6 +57,7 @@ export function SidebarSectionPlaceholder(props: {marker={props.marker}data-testid={`sidebar-${props.marker}`}className="relative mx-0.5 -mb-px h-0"+ revealOverflow={props.marker === "settled-placeholder" && props.showHint}>{props.showHint ? (<div