Skip to content
Snippets Groups Projects
Commit e04aa025 authored by Adrian Orłów's avatar Adrian Orłów
Browse files

fix: improve centering on pins selected from search

parent 1bfc48af
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!150fix: improve centering on pins selected from search (MIN-209)
Pipeline #87266 passed
import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { LOCATION_BTN_ID } from '@/components/Map/MapAdditionalActions/MappAdditionalActions.constants';
import { Icon } from '@/shared/Icon'; import { ZERO } from '@/constants/common';
import { displayBioEntitiesList } from '@/redux/drawer/drawer.slice'; import { displayBioEntitiesList } from '@/redux/drawer/drawer.slice';
import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch';
import { BioEntityContent } from '@/types/models'; import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { mapModelIdSelector, mapOpenedMapsSelector } from '@/redux/map/map.selectors'; import { mapModelIdSelector, mapOpenedMapsSelector } from '@/redux/map/map.selectors';
import { openMapAndSetActive, setActiveMap } from '@/redux/map/map.slice'; import { openMapAndSetActive, setActiveMap } from '@/redux/map/map.slice';
import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus'; import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
import { Icon } from '@/shared/Icon';
import { BioEntityContent } from '@/types/models';
export interface BioEntitiesSubmapItemProps { export interface BioEntitiesSubmapItemProps {
mapName: string; mapName: string;
...@@ -42,6 +44,11 @@ export const BioEntitiesSubmapItem = ({ ...@@ -42,6 +44,11 @@ export const BioEntitiesSubmapItem = ({
const onSubmapClick = (): void => { const onSubmapClick = (): void => {
openSubmap(); openSubmap();
dispatch(displayBioEntitiesList(bioEntities)); dispatch(displayBioEntitiesList(bioEntities));
const locationButton = document.querySelector<HTMLButtonElement>(`#${LOCATION_BTN_ID}`);
if (locationButton) {
setTimeout(() => locationButton?.click(), ZERO);
}
}; };
return ( return (
......
import { Icon } from '@/shared/Icon'; import { Icon } from '@/shared/Icon';
import { twMerge } from 'tailwind-merge'; import { twMerge } from 'tailwind-merge';
import { LOCATION_BTN_ID } from './MappAdditionalActions.constants';
import { useAddtionalActions } from './utils/useAdditionalActions'; import { useAddtionalActions } from './utils/useAdditionalActions';
export const MapAdditionalActions = (): JSX.Element => { export const MapAdditionalActions = (): JSX.Element => {
...@@ -18,6 +19,7 @@ export const MapAdditionalActions = (): JSX.Element => { ...@@ -18,6 +19,7 @@ export const MapAdditionalActions = (): JSX.Element => {
onClick={zoomInToBioEntities} onClick={zoomInToBioEntities}
data-testid="location-button" data-testid="location-button"
title="Center map" title="Center map"
id={LOCATION_BTN_ID}
> >
<Icon className="h-[28px] w-[28px]" name="location" /> <Icon className="h-[28px] w-[28px]" name="location" />
</button> </button>
......
export const MAP_ZOOM_IN_DELTA = 1; export const MAP_ZOOM_IN_DELTA = 1;
export const MAP_ZOOM_OUT_DELTA = -1; export const MAP_ZOOM_OUT_DELTA = -1;
export const LOCATION_BTN_ID = 'location-button';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment