Reset tags whenever new item is created

This commit is contained in:
pmoharana-cmd 2025-01-04 13:28:16 -05:00
parent 6eaf4e3729
commit e8a2186ae4

View File

@ -20,11 +20,14 @@ const CreateDrawer: FunctionComponent<CreateDrawerProps> = ({
const [isOpen, setIsOpen] = useState(false);
const [isFull, setIsFull] = useState(false);
const [newItemContent, setNewItemContent] = useState<any>({});
const [renderKey, setRenderKey] = useState(0);
const handleContentChange = (
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
) => {
const { name, value } = e.target;
console.log(newItemContent);
console.log(Object.keys(newItemContent).length);
setNewItemContent((prev: any) => ({
...prev,
[name]: value,
@ -52,6 +55,9 @@ const CreateDrawer: FunctionComponent<CreateDrawerProps> = ({
if (isFull) {
setIsFull(!isFull);
}
if (!isOpen) {
setRenderKey((prev) => prev + 1);
}
};
const toggleDrawerFullScreen = () => setIsFull(!isFull);
@ -106,6 +112,7 @@ const CreateDrawer: FunctionComponent<CreateDrawerProps> = ({
initializeSelectField(detail.key);
inputField = (
<TagsInput
key={`${detail.key}-${renderKey}`}
presetValue={[]}
presetOptions={
detail.presetOptionsValues || []