🐛 fix(inputListComponent): fix onChange event not being triggered when input value changes
✨ feat(inputListComponent): add PopUpContext to be able to close pop-ups when input value changes
This commit is contained in:
parent
4e01de9e39
commit
6cc4106c23
1 changed files with 7 additions and 2 deletions
|
|
@ -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 (
|
||||
<div
|
||||
className={
|
||||
|
|
@ -49,9 +54,9 @@ export default function InputListComponent({
|
|||
setInputList((old) => {
|
||||
let newInputList = _.cloneDeep(old);
|
||||
newInputList[idx] = e.target.value;
|
||||
onChange(newInputList);
|
||||
return newInputList;
|
||||
});
|
||||
onChange(inputList);
|
||||
}}
|
||||
/>
|
||||
{idx === inputList.length - 1 ? (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue