From 6cc4106c2336923edfe3423b8a446cffed55a1e1 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Fri, 23 Jun 2023 20:15:44 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(inputListComponent):=20fix?= =?UTF-8?q?=20onChange=20event=20not=20being=20triggered=20when=20input=20?= =?UTF-8?q?value=20changes=20=E2=9C=A8=20feat(inputListComponent):=20add?= =?UTF-8?q?=20PopUpContext=20to=20be=20able=20to=20close=20pop-ups=20when?= =?UTF-8?q?=20input=20value=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/components/inputListComponent/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/inputListComponent/index.tsx b/src/frontend/src/components/inputListComponent/index.tsx index 245ea93f0..f50626e15 100644 --- a/src/frontend/src/components/inputListComponent/index.tsx +++ b/src/frontend/src/components/inputListComponent/index.tsx @@ -5,6 +5,7 @@ import { TabsContext } from "../../contexts/tabsContext"; import _ from "lodash"; import { INPUT_STYLE } from "../../constants"; import { X, Plus } from "lucide-react"; +import { PopUpContext } from "../../contexts/popUpContext"; export default function InputListComponent({ value, @@ -13,6 +14,8 @@ export default function InputListComponent({ editNode = false, }: InputListComponentType) { const [inputList, setInputList] = useState(value ?? [""]); + const { closePopUp } = useContext(PopUpContext); + useEffect(() => { if (disabled) { setInputList([""]); @@ -22,8 +25,10 @@ export default function InputListComponent({ useEffect(() => { setInputList(value); - }, [value]); + }, [closePopUp]); + + return (
{ let newInputList = _.cloneDeep(old); newInputList[idx] = e.target.value; + onChange(newInputList); return newInputList; }); - onChange(inputList); }} /> {idx === inputList.length - 1 ? (