Make inputref reliable

This commit is contained in:
Zamil Majdy
2024-09-30 18:45:12 +02:00
parent 4e3df63dcd
commit 2f670c903d
3 changed files with 10 additions and 9 deletions

View File

@@ -427,7 +427,7 @@ export function CustomNode({ data, id, width, height }: NodeProps<CustomNode>) {
};
const deleteNode = useCallback(() => {
console.log("Deleting node:", id);
console.debug("Deleting node:", id);
// Remove the node
deleteElements({ nodes: [{ id }] });

View File

@@ -314,9 +314,13 @@ const NodeCredentialsInput: FC<{
const InputRef = (value: any): React.RefObject<HTMLInputElement> => {
const inputRef = React.useRef<HTMLInputElement>(null);
if (inputRef.current && value && inputRef.current.value !== value) {
inputRef.current.value = value;
}
useEffect(() => {
if (inputRef.current && value && inputRef.current.value !== value) {
inputRef.current.value = value;
}
}, [value]);
return inputRef;
};

View File

@@ -26,13 +26,10 @@ export function deepEquals(x: any, y: any): boolean {
ty = typeof y;
const res =
x &&
y &&
tx === ty &&
(tx === "object"
x && y && tx === ty && tx === "object"
? ok(x).length === ok(y).length &&
ok(x).every((key) => deepEquals(x[key], y[key]))
: x === y);
: x === y;
return res;
}