File tree Expand file tree Collapse file tree 5 files changed +42
-11
lines changed Expand file tree Collapse file tree 5 files changed +42
-11
lines changed Original file line number Diff line number Diff line change 136136 "react-dom" : " 18.2.0" ,
137137 "react-icons" : " 5.0.1" ,
138138 "react-use" : " 17.5.0" ,
139+ "react-virtuoso" : " 4.7.2" ,
139140 "tslib" : " 2.6.2" ,
140141 "tsx" : " 4.7.1" ,
141142 "typescript" : " 5.4.2" ,
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ const styles = stylex.create({
1717 flexDirection : 'row' ,
1818 // see https://github.com/facebook/stylex/issues/373
1919 width : '0' ,
20+ overflow : 'hidden' ,
2021 } ,
2122 action : {
2223 display : 'flex' ,
Original file line number Diff line number Diff line change @@ -47,16 +47,17 @@ function useStickyShadow() {
4747}
4848
4949interface TreeItemProps {
50- filePath : string
50+ className : string
5151 matches : DisplayResult [ ]
5252}
5353
54- const TreeItem = ( { filePath , matches } : TreeItemProps ) => {
54+ const TreeItem = ( { className , matches } : TreeItemProps ) => {
5555 const [ isExpanded , toggleIsExpanded ] = useBoolean ( true )
5656 const { isScrolled, ref } = useStickyShadow ( )
57+ const props = stylex . props ( styles . treeItem )
5758
5859 return (
59- < div { ... stylex . props ( styles . treeItem ) } >
60+ < div className = { ` ${ className } ${ props . className } ` } style = { props . style } >
6061 < div className = "scroll-observer" ref = { ref } />
6162 < TreeHeader
6263 isExpanded = { isExpanded }
Original file line number Diff line number Diff line change 1- import { memo } from 'react'
1+ import { memo , useCallback } from 'react'
22import { DisplayResult } from '../../../types'
33import TreeItem from './TreeItem'
44import * as stylex from '@stylexjs/stylex'
5+ import { Virtuoso } from 'react-virtuoso'
56
67const styles = stylex . create ( {
78 resultList : {
89 flexGrow : 1 ,
910 overflowY : 'scroll' ,
10- ':not(:hover) > div ::before' : {
11+ ':not(:hover) .sg-match-tree-item ::before' : {
1112 opacity : 0 ,
1213 } ,
13- ':hover > div ::before' : {
14+ ':hover .sg-match-tree-item ::before' : {
1415 opacity : 1 ,
1516 } ,
1617 } ,
@@ -21,12 +22,25 @@ interface SearchResultListProps {
2122}
2223
2324const SearchResultList = ( { matches } : SearchResultListProps ) => {
25+ const render = useCallback (
26+ ( index : number ) => {
27+ const [ filePath , match ] = matches [ index ]
28+ return (
29+ < TreeItem
30+ className = { 'sg-match-tree-item' }
31+ matches = { match }
32+ key = { filePath }
33+ />
34+ )
35+ } ,
36+ [ matches ] ,
37+ )
2438 return (
25- < div { ... stylex . props ( styles . resultList ) } >
26- { matches . map ( ( [ filePath , match ] ) => {
27- return < TreeItem filePath = { filePath } matches = { match } key = { filePath } />
28- } ) }
29- </ div >
39+ < Virtuoso
40+ { ... stylex . props ( styles . resultList ) }
41+ totalCount = { matches . length }
42+ itemContent = { render }
43+ / >
3044 )
3145}
3246
You can’t perform that action at this time.
0 commit comments