Jon/sky 5868 max recursion error in app (#3167)
This commit is contained in:
@@ -1,12 +1,6 @@
|
|||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import type { ChangeEventHandler, HTMLAttributes } from "react";
|
import type { ChangeEventHandler, HTMLAttributes } from "react";
|
||||||
import {
|
import { forwardRef, useEffect, useRef, useCallback } from "react";
|
||||||
forwardRef,
|
|
||||||
useEffect,
|
|
||||||
useLayoutEffect,
|
|
||||||
useRef,
|
|
||||||
useCallback,
|
|
||||||
} from "react";
|
|
||||||
import { cn } from "@/util/utils";
|
import { cn } from "@/util/utils";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -49,14 +43,6 @@ const AutoResizingTextarea = forwardRef<HTMLTextAreaElement, Props>(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
const textareaElement = getTextarea();
|
|
||||||
if (!textareaElement) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
textareaElement.style.height = `${textareaElement.scrollHeight + 2}px`;
|
|
||||||
}, [getTextarea]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const textareaElement = getTextarea();
|
const textareaElement = getTextarea();
|
||||||
if (!textareaElement) {
|
if (!textareaElement) {
|
||||||
|
|||||||
@@ -271,6 +271,7 @@ function FlowRenderer({
|
|||||||
const [debuggableBlockCount, setDebuggableBlockCount] = useState(0);
|
const [debuggableBlockCount, setDebuggableBlockCount] = useState(0);
|
||||||
const nodesInitialized = useNodesInitialized();
|
const nodesInitialized = useNodesInitialized();
|
||||||
const [shouldConstrainPan, setShouldConstrainPan] = useState(false);
|
const [shouldConstrainPan, setShouldConstrainPan] = useState(false);
|
||||||
|
const onNodesChangeTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (nodesInitialized) {
|
if (nodesInitialized) {
|
||||||
@@ -713,7 +714,15 @@ function FlowRenderer({
|
|||||||
) {
|
) {
|
||||||
workflowChangesStore.setHasChanges(true);
|
workflowChangesStore.setHasChanges(true);
|
||||||
}
|
}
|
||||||
onNodesChange(changes);
|
|
||||||
|
// prevent cascading React updates
|
||||||
|
if (onNodesChangeTimeoutRef.current) {
|
||||||
|
clearTimeout(onNodesChangeTimeoutRef.current);
|
||||||
|
}
|
||||||
|
|
||||||
|
onNodesChangeTimeoutRef.current = setTimeout(() => {
|
||||||
|
onNodesChange(changes);
|
||||||
|
}, 0); // defer to next tick
|
||||||
}}
|
}}
|
||||||
onEdgesChange={onEdgesChange}
|
onEdgesChange={onEdgesChange}
|
||||||
nodeTypes={nodeTypes}
|
nodeTypes={nodeTypes}
|
||||||
|
|||||||
Reference in New Issue
Block a user