@@ -1042,6 +1042,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
10421042 const [ renamingTitle , setRenamingTitle ] = useState ( "" ) ;
10431043 const settlingThreadKeysRef = useRef ( new Set < string > ( ) ) ;
10441044 const threadListRef = useRef < HTMLUListElement | null > ( null ) ;
1045+ const searchResultsListRef = useRef < HTMLUListElement | null > ( null ) ;
10451046 const sidebarContentRef = useRef < HTMLDivElement | null > ( null ) ;
10461047 const dragLabelOffsetRef = useRef ( 0 ) ;
10471048 const listMotionRef = useRef < ReturnType < typeof createSidebarListMotion > | null > ( null ) ;
@@ -1738,7 +1739,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
17381739 } ) ;
17391740 } ;
17401741 const pointerOutsideThreadList = ( point : { x : number ; y : number } ) => {
1741- const bounds = threadListRef . current ?. getBoundingClientRect ( ) ;
1742+ // Search results replace the thread list, so only one of them is mounted.
1743+ const bounds = ( threadListRef . current ?? searchResultsListRef . current ) ?. getBoundingClientRect ( ) ;
17421744 return bounds !== undefined && ( point . x < bounds . left || point . x > bounds . right ) ;
17431745 } ;
17441746 // The path out of the list often crosses dnd-kit's edge zone, which autoscrolls the sidebar.
@@ -3225,57 +3227,66 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
32253227 closeDelay = { 0 }
32263228 timeout = { 400 }
32273229 >
3228- < ul
3229- id = "sidebar-thread-search-results"
3230- role = "listbox"
3231- aria-label = "Thread search results"
3232- className = "flex flex-col gap-px"
3230+ < DndContext
3231+ sensors = { dndSensors }
3232+ autoScroll = { false }
3233+ onDragStart = { ( event ) => {
3234+ contextDragKeyRef . current = String ( event . active . id ) ;
3235+ } }
32333236 >
3234- { threadSearchResults . map ( ( thread , index ) => {
3235- const threadKey = scopedThreadKey (
3236- scopeThreadRef ( thread . environmentId , thread . id ) ,
3237- ) ;
3238- return (
3239- < SidebarSearchResultRow
3240- isSettled = { settledThreadKeys . has ( threadKey ) }
3241- key = { threadKey }
3242- thread = { thread }
3243- project = {
3244- projectByKey . get ( `${ thread . environmentId } :${ thread . projectId } ` ) ?? null
3245- }
3246- projectDisplayName = {
3247- projectDisplayNameByKey . get (
3248- `${ thread . environmentId } :${ thread . projectId } ` ,
3249- ) ?? null
3250- }
3251- environmentLabel = { environmentLabelById . get ( thread . environmentId ) ?? null }
3252- environmentMachine = {
3253- environmentMachineById . get ( thread . environmentId ) ?? "server"
3254- }
3255- providerEntryByInstanceId = {
3256- providerEntriesByEnvironment . get ( thread . environmentId ) ??
3257- EMPTY_PROVIDER_ENTRIES
3258- }
3259- isHighlighted = { activeSearchResultIndex === index }
3260- isRouteActive = { routeRowThreadKey === threadKey }
3261- resultId = { threadSearchResultId ( index ) }
3262- searchMatch = {
3263- threadSearchMatchByKey . get (
3264- threadSearchMatchKey ( {
3265- environmentId : thread . environmentId ,
3266- threadId : thread . id ,
3267- } ) ,
3268- ) ?? null
3269- }
3270- searchQuery = { threadSearchQuery }
3271- searchMatchQuery = { threadSearch . query }
3272- onHighlight = { ( ) => setActiveSearchResultIndex ( index ) }
3273- onSelect = { ( ) => selectThreadSearchResult ( thread ) }
3274- onFileDropThreads = { handleThreadFileDrop }
3275- />
3276- ) ;
3277- } ) }
3278- </ ul >
3237+ < ul
3238+ ref = { searchResultsListRef }
3239+ id = "sidebar-thread-search-results"
3240+ role = "listbox"
3241+ aria-label = "Thread search results"
3242+ className = "flex flex-col gap-px"
3243+ >
3244+ { threadSearchResults . map ( ( thread , index ) => {
3245+ const threadKey = scopedThreadKey (
3246+ scopeThreadRef ( thread . environmentId , thread . id ) ,
3247+ ) ;
3248+ return (
3249+ < SidebarSearchResultRow
3250+ isSettled = { settledThreadKeys . has ( threadKey ) }
3251+ key = { threadKey }
3252+ thread = { thread }
3253+ project = {
3254+ projectByKey . get ( `${ thread . environmentId } :${ thread . projectId } ` ) ?? null
3255+ }
3256+ projectDisplayName = {
3257+ projectDisplayNameByKey . get (
3258+ `${ thread . environmentId } :${ thread . projectId } ` ,
3259+ ) ?? null
3260+ }
3261+ environmentLabel = { environmentLabelById . get ( thread . environmentId ) ?? null }
3262+ environmentMachine = {
3263+ environmentMachineById . get ( thread . environmentId ) ?? "server"
3264+ }
3265+ providerEntryByInstanceId = {
3266+ providerEntriesByEnvironment . get ( thread . environmentId ) ??
3267+ EMPTY_PROVIDER_ENTRIES
3268+ }
3269+ isHighlighted = { activeSearchResultIndex === index }
3270+ isRouteActive = { routeRowThreadKey === threadKey }
3271+ resultId = { threadSearchResultId ( index ) }
3272+ searchMatch = {
3273+ threadSearchMatchByKey . get (
3274+ threadSearchMatchKey ( {
3275+ environmentId : thread . environmentId ,
3276+ threadId : thread . id ,
3277+ } ) ,
3278+ ) ?? null
3279+ }
3280+ searchQuery = { threadSearchQuery }
3281+ searchMatchQuery = { threadSearch . query }
3282+ onHighlight = { ( ) => setActiveSearchResultIndex ( index ) }
3283+ onSelect = { ( ) => selectThreadSearchResult ( thread ) }
3284+ onFileDropThreads = { handleThreadFileDrop }
3285+ />
3286+ ) ;
3287+ } ) }
3288+ </ ul >
3289+ </ DndContext >
32793290 </ TooltipProvider >
32803291 ) : (
32813292 < p
0 commit comments