Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/features/search/atoms/highlightedGeometry.ts

This file was deleted.

34 changes: 5 additions & 29 deletions src/features/search/componets/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SelectItem } from '@konturio/ui-kit';
import { useAction, useAtom } from '@reatom/npm-react';
import cn from 'clsx';
import { forwardRef, useEffect } from 'react';
import { forwardRef } from 'react';
import { searchLocationsAtom } from '~features/search/searchLocationAtoms';
import {
itemSelectAction,
Expand All @@ -16,9 +16,6 @@ import {
MCDASuggestionAtom,
} from '~features/search/searchMcdaAtoms';
import { SearchInput } from '~components/Search/SearchInput/SearchInput';
import { searchHighlightedGeometryAtom } from '../../atoms/highlightedGeometry';
import type { Feature } from 'geojson';
import { EMPTY_HIGHLIGHT } from '../../constants';
import { useSearchMenu } from '~utils/hooks/useSearchMenu';
import style from './SearchBar.module.css';
import type { AggregatedSearchItem } from '~features/search/searchAtoms';
Expand All @@ -36,27 +33,19 @@ export const SearchBar = forwardRef<HTMLInputElement, SearchBarProps>(
? i18n.t('search.input_placeholder_mcda')
: i18n.t('search.input_placeholder');

const search = useAction(searchAction);
const itemSelectActionFn = useAction(itemSelectAction);
const reset = useAction(resetSearchAction);
const setHighlightedGeometry = useAction(searchHighlightedGeometryAtom);
const search = useAction(searchAction);
const itemSelectActionFn = useAction(itemSelectAction);
const reset = useAction(resetSearchAction);

const itemSelect = (item: AggregatedSearchItem) => {
itemSelectActionFn(item);
setHighlightedGeometry(EMPTY_HIGHLIGHT);
onItemSelect?.();
};

const [{ error, loading, data }] = useAtom(searchLocationsAtom);
const emptyLocations = data ? data.length === 0 : false;
const [mcdaSearchStatus] = useAtom(MCDASuggestionAtom);
const [aggregatedResults] = useAtom(aggregatedSearchAtom);

useEffect(() => {
return () => {
setHighlightedGeometry(EMPTY_HIGHLIGHT);
};
}, [setHighlightedGeometry]);
const [aggregatedResults] = useAtom(aggregatedSearchAtom);

const renderError = () => (
<SelectItem
Expand Down Expand Up @@ -102,11 +91,6 @@ export const SearchBar = forwardRef<HTMLInputElement, SearchBarProps>(
className={style.listItem}
itemProps={{
onClick: () => handleItemSelect(item),
onMouseEnter: () =>
item.geometry &&
setHighlightedGeometry(item as Feature),
onMouseLeave: () =>
setHighlightedGeometry(EMPTY_HIGHLIGHT),
role: 'option',
}}
/>
Expand All @@ -124,10 +108,6 @@ export const SearchBar = forwardRef<HTMLInputElement, SearchBarProps>(
highlighted={highlightedIndex === index}
itemProps={{
onClick: () => handleItemSelect(item),
onMouseEnter: () =>
setHighlightedGeometry(EMPTY_HIGHLIGHT),
onMouseLeave: () =>
setHighlightedGeometry(EMPTY_HIGHLIGHT),
role: 'option',
}}
/>
Expand Down Expand Up @@ -167,10 +147,6 @@ export const SearchBar = forwardRef<HTMLInputElement, SearchBarProps>(
emptyLocations,
});

useEffect(() => {
if (!isMenuOpen) setHighlightedGeometry(EMPTY_HIGHLIGHT);
}, [isMenuOpen, setHighlightedGeometry]);

return (
<>
<div className={cn(style.searchBar, searchBarClass)} ref={searchBarRef}>
Expand Down
8 changes: 0 additions & 8 deletions src/features/search/constants.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/features/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { i18n } from '~core/localization';
import { useShortPanelState } from '~utils/hooks/useShortPanelState';
import { useAutoCollapsePanel } from '~utils/hooks/useAutoCollapsePanel';
import { SearchBar } from '~features/search/componets/SearchBar/SearchBar';
import { initSearchHighlightLayer } from './initSearchHighlightLayer';
import s from './styles.module.css';

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

useEffect(() => {
const destroyHighlightLayer = initSearchHighlightLayer();
return () => {
destroyHighlightLayer?.();
};
}, []);

useEffect(() => {
if (isOpen && isMobile) {
inputRef?.current?.focus(); // triggers phone keyboard
Expand Down
74 changes: 0 additions & 74 deletions src/features/search/initSearchHighlightLayer.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/features/search/readme.md

This file was deleted.

3 changes: 0 additions & 3 deletions src/features/search/renderers/SearchHighlightRenderer.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/features/search/searchAtoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {
selectMCDAItemAction,
isMCDASearchEnabled,
} from '~features/search/searchMcdaAtoms';
import { searchHighlightedGeometryAtom } from './atoms/highlightedGeometry';
import { EMPTY_HIGHLIGHT } from './constants';
import type { LocationProperties } from '~core/api/search';
import type { Geometry } from 'geojson';
import type { MCDAConfig } from '~core/logical_layers/renderers/stylesConfigs/mcda/types';
Expand Down Expand Up @@ -65,7 +63,6 @@ export const itemSelectAction = action((ctx, item: AggregatedSearchItem) => {
} else if (item.source === 'mcda') {
selectMCDAItemAction(ctx);
}
searchHighlightedGeometryAtom(ctx, EMPTY_HIGHLIGHT);
});

export const resetSearchAction = action((ctx) => {
Expand Down
13 changes: 1 addition & 12 deletions src/features/search/searchLocationAtoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import {
withStatusesAtom,
} from '@reatom/framework';
import { getLocations } from '~core/api/search';
import {
setCurrentMapBbox,
focusOnGeometry,
} from '~core/shared_state/currentMapPosition';
import { focusedGeometryAtom } from '~core/focused_geometry/model';
import { setCurrentMapBbox } from '~core/shared_state/currentMapPosition';

export const fetchLocationsAsyncResource = reatomAsync(
(ctx, query: string) => getLocations(query, ctx.controller),
Expand All @@ -32,13 +28,6 @@ export const searchLocationsAtom = atom((ctx) => {
export const selectLocationItemAction = action((ctx, item) => {
const bbox = item.properties.bbox;
setCurrentMapBbox(ctx, bbox);
if (item.geometry) {
focusedGeometryAtom.setFocusedGeometry.v3action(ctx, {
source: { type: 'custom' },
geometry: item,
});
focusOnGeometry(ctx, item);
}
});

export const resetLocationSearchAction = action((ctx) => {
Expand Down
Loading