Skip to content

Commit e112d77

Browse files
authored
Revert "feat(search): 22291 select area when location chosen (#1194)" (#1248)
This reverts commit 16eee94.
1 parent 44377fa commit e112d77

File tree

9 files changed

+6
-159
lines changed

9 files changed

+6
-159
lines changed

src/features/search/atoms/highlightedGeometry.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/features/search/componets/SearchBar/SearchBar.tsx

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { SelectItem } from '@konturio/ui-kit';
22
import { useAction, useAtom } from '@reatom/npm-react';
33
import cn from 'clsx';
4-
import { forwardRef, useEffect } from 'react';
4+
import { forwardRef } from 'react';
55
import { searchLocationsAtom } from '~features/search/searchLocationAtoms';
66
import {
77
itemSelectAction,
@@ -16,9 +16,6 @@ import {
1616
MCDASuggestionAtom,
1717
} from '~features/search/searchMcdaAtoms';
1818
import { SearchInput } from '~components/Search/SearchInput/SearchInput';
19-
import { searchHighlightedGeometryAtom } from '../../atoms/highlightedGeometry';
20-
import type { Feature } from 'geojson';
21-
import { EMPTY_HIGHLIGHT } from '../../constants';
2219
import { useSearchMenu } from '~utils/hooks/useSearchMenu';
2320
import style from './SearchBar.module.css';
2421
import 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}>

src/features/search/constants.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/features/search/index.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { i18n } from '~core/localization';
77
import { useShortPanelState } from '~utils/hooks/useShortPanelState';
88
import { useAutoCollapsePanel } from '~utils/hooks/useAutoCollapsePanel';
99
import { SearchBar } from '~features/search/componets/SearchBar/SearchBar';
10-
import { initSearchHighlightLayer } from './initSearchHighlightLayer';
1110
import s from './styles.module.css';
1211

1312
export function Search() {
@@ -19,13 +18,6 @@ export function Search() {
1918
const inputRef = useRef<HTMLInputElement>(null);
2019
const isMobile = useMediaQuery(IS_MOBILE_QUERY);
2120

22-
useEffect(() => {
23-
const destroyHighlightLayer = initSearchHighlightLayer();
24-
return () => {
25-
destroyHighlightLayer?.();
26-
};
27-
}, []);
28-
2921
useEffect(() => {
3022
if (isOpen && isMobile) {
3123
inputRef?.current?.focus(); // triggers phone keyboard

src/features/search/initSearchHighlightLayer.ts

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/features/search/readme.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/features/search/renderers/SearchHighlightRenderer.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/features/search/searchAtoms.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import {
1212
selectMCDAItemAction,
1313
isMCDASearchEnabled,
1414
} from '~features/search/searchMcdaAtoms';
15-
import { searchHighlightedGeometryAtom } from './atoms/highlightedGeometry';
16-
import { EMPTY_HIGHLIGHT } from './constants';
1715
import type { LocationProperties } from '~core/api/search';
1816
import type { Geometry } from 'geojson';
1917
import type { MCDAConfig } from '~core/logical_layers/renderers/stylesConfigs/mcda/types';
@@ -65,7 +63,6 @@ export const itemSelectAction = action((ctx, item: AggregatedSearchItem) => {
6563
} else if (item.source === 'mcda') {
6664
selectMCDAItemAction(ctx);
6765
}
68-
searchHighlightedGeometryAtom(ctx, EMPTY_HIGHLIGHT);
6966
});
7067

7168
export const resetSearchAction = action((ctx) => {

src/features/search/searchLocationAtoms.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import {
88
withStatusesAtom,
99
} from '@reatom/framework';
1010
import { getLocations } from '~core/api/search';
11-
import {
12-
setCurrentMapBbox,
13-
focusOnGeometry,
14-
} from '~core/shared_state/currentMapPosition';
15-
import { focusedGeometryAtom } from '~core/focused_geometry/model';
11+
import { setCurrentMapBbox } from '~core/shared_state/currentMapPosition';
1612

1713
export const fetchLocationsAsyncResource = reatomAsync(
1814
(ctx, query: string) => getLocations(query, ctx.controller),
@@ -32,13 +28,6 @@ export const searchLocationsAtom = atom((ctx) => {
3228
export const selectLocationItemAction = action((ctx, item) => {
3329
const bbox = item.properties.bbox;
3430
setCurrentMapBbox(ctx, bbox);
35-
if (item.geometry) {
36-
focusedGeometryAtom.setFocusedGeometry.v3action(ctx, {
37-
source: { type: 'custom' },
38-
geometry: item,
39-
});
40-
focusOnGeometry(ctx, item);
41-
}
4231
});
4332

4433
export const resetLocationSearchAction = action((ctx) => {

0 commit comments

Comments
 (0)