@@ -104,6 +104,8 @@ export function SearchBar<T extends string>({
104104 SearchBarTokenEquation [ ]
105105 > ( [ ] ) ;
106106
107+ const currentFilters = useRef < string | null > ( null ) ;
108+
107109 const [ suggestions , setSuggestions ] = useState < SearchBarSuggestions > ( {
108110 items : [ ] ,
109111 nature : [ ] ,
@@ -127,7 +129,11 @@ export function SearchBar<T extends string>({
127129
128130 // Effect to initialize the token equations from filters
129131 useEffect ( ( ) => {
130- if ( tokenEquations . length !== 0 ) return ; // Avoid reloading if already loaded
132+ const newFiltersString = String (
133+ filters . map ( ( filter ) => JSON . stringify ( filter ) ) ,
134+ ) ;
135+
136+ if ( currentFilters && currentFilters . current === newFiltersString ) return ; // Avoid reloading if already loaded
131137
132138 async function load ( ) {
133139 const promises = filters . map ( async ( filter , filterIndex ) =>
@@ -137,14 +143,15 @@ export function SearchBar<T extends string>({
137143 setTokenEquations ( newTokenEquations ) ;
138144 }
139145
140- if ( filters . length !== 0 && tokenEquations . length === 0 ) load ( ) ;
141- } , [ ] ) ;
146+ if ( filters . length !== 0 ) load ( ) ;
147+ currentFilters . current = newFiltersString ;
148+ } , [ filters , createSuggestions , currentFilters , tokenEquations . length ] ) ;
142149
143150 const usesCurrentInput = useMemo (
144151 ( ) => functionUsesCurrentInput ( createSuggestions ) ,
145152 [ createSuggestions ] ,
146153 ) ;
147- // Create a list of options based on the current tokens and data
154+
148155 useEffect ( ( ) => {
149156 async function load ( ) {
150157 const params : CreateSuggestionsParams = {
@@ -324,15 +331,17 @@ export function SearchBar<T extends string>({
324331 display : "flex" ,
325332 border : "1px solid" ,
326333 borderColor : "grey.400" ,
327- overflow : "auto " ,
334+ overflow : "hidden " ,
328335 borderRadius : 1 ,
329336 ":focus-within" : {
330337 borderColor : "primary.main" ,
331338 } ,
332339 } }
333340 data-testid = "search-bar"
334341 >
335- < Box sx = { { gap : 1 , display : "flex" , padding : 1 , width : 0.9 } } >
342+ < Box
343+ sx = { { gap : 1 , display : "flex" , padding : 1 , width : 1 , overflow : "auto" } }
344+ >
336345 { tokenEquations . map ( ( equation , index ) => (
337346 < DisplayTokenEquation
338347 key = { index }
0 commit comments