Skip to content
Snippets Groups Projects
Commit e16099c3 authored by mateusz-winiarczyk's avatar mateusz-winiarczyk
Browse files

Merge branch 'MIN-290-invalid-pin-position-after-submap-close' into 'development'

fix(submap): invalid pin position after submap is closed (MIN-290)

See merge request !135
parents 6a321893 ba37e197
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...,!135fix(submap): invalid pin position after submap is closed (MIN-290)
Pipeline #86704 passed
......@@ -6,6 +6,7 @@ import {
import { StoreType } from '@/redux/store';
import { initialMapDataFixture, openedMapsThreeSubmapsFixture } from '@/redux/map/map.fixtures';
import { act, render, screen, within } from '@testing-library/react';
import { MODELS_MOCK } from '@/redux/compartmentPathways/compartmentPathways.mock';
import { MODELS_DATA_MOCK_WITH_MAIN_MAP } from '@/redux/models/models.mock';
import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
import { MapNavigation } from './MapNavigation.component';
......@@ -104,9 +105,8 @@ describe('MapNavigation - component', () => {
expect(modelId).toBe(MAIN_MAP_ID);
});
it('should close map and open main map if closed currently selected map', async () => {
it('should close currently selected map map and open main map', async () => {
const { store } = renderComponent({
models: MODELS_DATA_MOCK_WITH_MAIN_MAP,
map: {
data: {
...initialMapDataFixture,
......@@ -116,6 +116,11 @@ describe('MapNavigation - component', () => {
loading: 'succeeded',
error: { message: '', name: '' },
},
models: {
loading: 'succeeded',
error: { message: '', name: '' },
data: MODELS_MOCK,
},
});
const histamineMapButton = screen.getByRole('button', { name: 'Histamine signaling' });
......
......@@ -23,7 +23,12 @@ export const MapNavigation = (): JSX.Element => {
const onCloseSubmap = (event: MouseEvent<HTMLDivElement>, map: OppenedMap): void => {
event.stopPropagation();
if (isActive(map.modelId)) {
dispatch(closeMapAndSetMainMapActive({ modelId: map.modelId }));
dispatch(
closeMapAndSetMainMapActive({
modelId: mainMapModel.idObject,
currentModelId: map.modelId,
}),
);
PluginsEventBus.dispatchEvent('onSubmapClose', map.modelId);
PluginsEventBus.dispatchEvent('onSubmapOpen', mainMapModel.idObject);
......
import { ZERO } from '@/constants/common';
import { DEFAULT_ZOOM } from '@/constants/map';
import { ActionReducerMapBuilder } from '@reduxjs/toolkit';
import { PluginsEventBus } from '@/services/pluginsManager/pluginsEventBus';
import { getPointMerged } from '../../utils/object/getPointMerged';
import { MAIN_MAP } from './map.constants';
import {
initMapBackground,
initMapPosition,
......@@ -12,6 +10,7 @@ import {
} from './map.thunks';
import {
CloseMapAction,
CloseMapActionAndSetMainMapActive,
MapState,
OpenMapAndSetActiveAction,
SetActiveMapAction,
......@@ -99,13 +98,12 @@ export const closeMapReducer = (state: MapState, action: CloseMapAction): void =
export const closeMapAndSetMainMapActiveReducer = (
state: MapState,
action: CloseMapAction,
action: CloseMapActionAndSetMainMapActive,
): void => {
state.openedMaps = state.openedMaps.filter(
openedMap => openedMap.modelId !== action.payload.modelId,
openedMap => openedMap.modelId !== action.payload.currentModelId,
);
state.data.modelId =
state.openedMaps.find(openedMap => openedMap.modelName === MAIN_MAP)?.modelId || ZERO;
state.data.modelId = action.payload.modelId;
};
export const setMapBackgroundReducer = (state: MapState, action: SetBackgroundAction): void => {
......
......@@ -64,6 +64,12 @@ export type CloseMapActionPayload = Pick<OppenedMap, 'modelId'>;
export type CloseMapAction = PayloadAction<CloseMapActionPayload>;
export type CloseMapActionAndSetMainMapActive = PayloadAction<
{
currentModelId: number;
} & Pick<OppenedMap, 'modelId'>
>;
export type InitMapDataActionParams = { queryData: QueryData };
export type InitMapDataAction = PayloadAction<SetMapDataAction>;
......
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