Fix issue-4276: UI: Filter Schema once added unable to remove (#4320)

This commit is contained in:
Shailesh Parmar 2022-04-22 10:16:47 +05:30 committed by GitHub
parent eccbbe11c7
commit d41bf6cab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@
import { isUndefined } from 'lodash';
import React, { KeyboardEventHandler, useState } from 'react';
import { MultiValue } from 'react-select';
import CreatableSelect from 'react-select/creatable';
import { reactSelectCustomStyle } from './reactSelectCustomStyle';
@ -52,6 +53,12 @@ const ReactSelectMultiInput = ({
setinputValue(input);
};
const handleChange = (newValue: MultiValue<unknown>) => {
const data = newValue as Option[];
setValues(data);
getTagValue(data.map((v) => v.value));
};
const handleKeyDown: KeyboardEventHandler<HTMLDivElement> = (event) => {
if (!inputValue) return;
switch (event.key) {
@ -76,6 +83,7 @@ const ReactSelectMultiInput = ({
placeholder={placeholder}
styles={reactSelectCustomStyle}
value={values}
onChange={handleChange}
onInputChange={handleInputChange}
onKeyDown={handleKeyDown}
/>