Skip to content

Commit

Permalink
fix: avoid unmounts in spectra panel (#2197)
Browse files Browse the repository at this point in the history
Closes: #1901
  • Loading branch information
targos committed Feb 23, 2023
1 parent 5c0556d commit fc2f07a
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/component/panels/SpectrumsPanel/SpectrumsTabs.tsx
@@ -1,6 +1,6 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { useState, useMemo, memo } from 'react';
import { useState, useMemo, memo, useCallback } from 'react';

import { Datum1D } from '../../../data/types/data1d';
import { Datum2D } from '../../../data/types/data2d';
Expand Down Expand Up @@ -49,25 +49,28 @@ function SpectrumsTabsInner({
dispatch({ type: SET_ACTIVE_TAB, tab: tab.tabid });
}

function openSettingHandler(event, selectedSpectrum) {
const openSettingHandler = useCallback((event, selectedSpectrum) => {
event.stopPropagation();
setSettingModalPosition({
x: event.nativeEvent.clientX,
y: event.nativeEvent.clientY,
});
setSelectedSpectrum(selectedSpectrum);
setIsSettingModalDisplayed(true);
}
}, []);

function handleChangeVisibility(d, key) {
dispatch({
type: CHANGE_VISIBILITY,
payload: {
id: d.id,
key,
},
});
}
const handleChangeVisibility = useCallback(
(d, key) => {
dispatch({
type: CHANGE_VISIBILITY,
payload: {
id: d.id,
key,
},
});
},
[dispatch],
);

function handleChangeActiveSpectrum(e, spectrum) {
setTimeout(() => {
Expand Down

0 comments on commit fc2f07a

Please sign in to comment.