mirror of
https://github.com/cssgunc/compass.git
synced 2025-04-03 19:40:16 -04:00
Reset tags whenever new item is created
This commit is contained in:
parent
6eaf4e3729
commit
e8a2186ae4
|
@ -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 || []
|
||||
|
|
Loading…
Reference in New Issue
Block a user