fix: tags is grabbed from the local state (#2106)

This commit is contained in:
Palash Gupta 2023-01-24 17:42:48 +05:30 committed by GitHub
parent f1c7d72fc5
commit 2f1ca93eda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -1,8 +1,6 @@
import { CloseOutlined } from '@ant-design/icons';
import { Select } from 'antd';
import React from 'react';
import { useSelector } from 'react-redux';
import { AppState } from 'store/reducers';
import { TraceReducer } from 'types/reducer/trace';
import { Container, IconContainer, SelectComponent } from './styles';
@ -30,9 +28,13 @@ const AllMenu: AllMenuProps[] = [
];
function SingleTags(props: AllTagsProps): JSX.Element {
const traces = useSelector<AppState, TraceReducer>((state) => state.traces);
const { tag, onCloseHandler, setLocalSelectedTags, index } = props;
const {
tag,
onCloseHandler,
setLocalSelectedTags,
index,
localSelectedTags,
} = props;
const {
Key: selectedKey,
Operator: selectedOperator,
@ -46,13 +48,13 @@ function SingleTags(props: AllTagsProps): JSX.Element {
const onChangeOperatorHandler = (key: unknown): void => {
if (typeof key === 'string') {
setLocalSelectedTags([
...traces.selectedTags.slice(0, index),
...localSelectedTags.slice(0, index),
{
Key: selectedKey,
Values: selectedValues,
Operator: key as Tags,
},
...traces.selectedTags.slice(index + 1, traces.selectedTags.length),
...localSelectedTags.slice(index + 1, localSelectedTags.length),
]);
}
};
@ -100,6 +102,7 @@ interface AllTagsProps {
setLocalSelectedTags: React.Dispatch<
React.SetStateAction<TraceReducer['selectedTags']>
>;
localSelectedTags: TraceReducer['selectedTags'];
}
export interface Value {

View File

@ -99,6 +99,7 @@ function AllTags({
index={index}
onCloseHandler={(): void => onCloseHandler(index)}
setLocalSelectedTags={setLocalSelectedTags}
localSelectedTags={localSelectedTags}
/>
))}
</CurrentTagsContainer>