11import { SelectItem } from '@konturio/ui-kit' ;
22import { useAction , useAtom } from '@reatom/npm-react' ;
33import cn from 'clsx' ;
4- import { forwardRef , useEffect } from 'react' ;
4+ import { forwardRef } from 'react' ;
55import { searchLocationsAtom } from '~features/search/searchLocationAtoms' ;
66import {
77 itemSelectAction ,
@@ -16,9 +16,6 @@ import {
1616 MCDASuggestionAtom ,
1717} from '~features/search/searchMcdaAtoms' ;
1818import { SearchInput } from '~components/Search/SearchInput/SearchInput' ;
19- import { searchHighlightedGeometryAtom } from '../../atoms/highlightedGeometry' ;
20- import type { Feature } from 'geojson' ;
21- import { EMPTY_HIGHLIGHT } from '../../constants' ;
2219import { useSearchMenu } from '~utils/hooks/useSearchMenu' ;
2320import style from './SearchBar.module.css' ;
2421import type { AggregatedSearchItem } from '~features/search/searchAtoms' ;
@@ -36,27 +33,19 @@ export const SearchBar = forwardRef<HTMLInputElement, SearchBarProps>(
3633 ? i18n . t ( 'search.input_placeholder_mcda' )
3734 : i18n . t ( 'search.input_placeholder' ) ;
3835
39- const search = useAction ( searchAction ) ;
40- const itemSelectActionFn = useAction ( itemSelectAction ) ;
41- const reset = useAction ( resetSearchAction ) ;
42- const setHighlightedGeometry = useAction ( searchHighlightedGeometryAtom ) ;
36+ const search = useAction ( searchAction ) ;
37+ const itemSelectActionFn = useAction ( itemSelectAction ) ;
38+ const reset = useAction ( resetSearchAction ) ;
4339
4440 const itemSelect = ( item : AggregatedSearchItem ) => {
4541 itemSelectActionFn ( item ) ;
46- setHighlightedGeometry ( EMPTY_HIGHLIGHT ) ;
4742 onItemSelect ?.( ) ;
4843 } ;
4944
5045 const [ { error, loading, data } ] = useAtom ( searchLocationsAtom ) ;
5146 const emptyLocations = data ? data . length === 0 : false ;
5247 const [ mcdaSearchStatus ] = useAtom ( MCDASuggestionAtom ) ;
53- const [ aggregatedResults ] = useAtom ( aggregatedSearchAtom ) ;
54-
55- useEffect ( ( ) => {
56- return ( ) => {
57- setHighlightedGeometry ( EMPTY_HIGHLIGHT ) ;
58- } ;
59- } , [ setHighlightedGeometry ] ) ;
48+ const [ aggregatedResults ] = useAtom ( aggregatedSearchAtom ) ;
6049
6150 const renderError = ( ) => (
6251 < SelectItem
@@ -102,11 +91,6 @@ export const SearchBar = forwardRef<HTMLInputElement, SearchBarProps>(
10291 className = { style . listItem }
10392 itemProps = { {
10493 onClick : ( ) => handleItemSelect ( item ) ,
105- onMouseEnter : ( ) =>
106- item . geometry &&
107- setHighlightedGeometry ( item as Feature ) ,
108- onMouseLeave : ( ) =>
109- setHighlightedGeometry ( EMPTY_HIGHLIGHT ) ,
11094 role : 'option' ,
11195 } }
11296 />
@@ -124,10 +108,6 @@ export const SearchBar = forwardRef<HTMLInputElement, SearchBarProps>(
124108 highlighted = { highlightedIndex === index }
125109 itemProps = { {
126110 onClick : ( ) => handleItemSelect ( item ) ,
127- onMouseEnter : ( ) =>
128- setHighlightedGeometry ( EMPTY_HIGHLIGHT ) ,
129- onMouseLeave : ( ) =>
130- setHighlightedGeometry ( EMPTY_HIGHLIGHT ) ,
131111 role : 'option' ,
132112 } }
133113 />
@@ -167,10 +147,6 @@ export const SearchBar = forwardRef<HTMLInputElement, SearchBarProps>(
167147 emptyLocations ,
168148 } ) ;
169149
170- useEffect ( ( ) => {
171- if ( ! isMenuOpen ) setHighlightedGeometry ( EMPTY_HIGHLIGHT ) ;
172- } , [ isMenuOpen , setHighlightedGeometry ] ) ;
173-
174150 return (
175151 < >
176152 < div className = { cn ( style . searchBar , searchBarClass ) } ref = { searchBarRef } >
0 commit comments