Fixed Undo bug when adding edge to input with text (#1900)
This commit is contained in:
commit
06afef340e
10 changed files with 26 additions and 25 deletions
|
|
@ -18,12 +18,12 @@ export default function CodeAreaComponent({
|
|||
setOpen,
|
||||
}: CodeAreaComponentType) {
|
||||
const [myValue, setMyValue] = useState(
|
||||
typeof value == "string" ? value : JSON.stringify(value)
|
||||
typeof value == "string" ? value : JSON.stringify(value),
|
||||
);
|
||||
useEffect(() => {
|
||||
if (disabled && myValue !== "") {
|
||||
setMyValue("");
|
||||
onChange("");
|
||||
onChange("", true);
|
||||
}
|
||||
}, [disabled]);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export default function FloatComponent({
|
|||
// Clear component state
|
||||
useEffect(() => {
|
||||
if (disabled && value !== "") {
|
||||
onChange("");
|
||||
onChange("", true);
|
||||
}
|
||||
}, [disabled]);
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export default function InputComponent({
|
|||
// Clear component state
|
||||
useEffect(() => {
|
||||
if (disabled && value && onChange && value !== "") {
|
||||
onChange("");
|
||||
onChange("", true);
|
||||
}
|
||||
}, [disabled]);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export default function InputFileComponent({
|
|||
useEffect(() => {
|
||||
if (disabled && value !== "") {
|
||||
setMyValue("");
|
||||
onChange("");
|
||||
onChange("", true);
|
||||
onFileChange("");
|
||||
}
|
||||
}, [disabled, onChange]);
|
||||
|
|
@ -106,8 +106,8 @@ export default function InputFileComponent({
|
|||
editNode
|
||||
? "input-edit-node input-dialog text-muted-foreground"
|
||||
: disabled
|
||||
? "input-disable input-dialog primary-input"
|
||||
: "input-dialog primary-input text-muted-foreground"
|
||||
? "input-disable input-dialog primary-input"
|
||||
: "input-dialog primary-input text-muted-foreground"
|
||||
}
|
||||
>
|
||||
{myValue !== "" ? myValue : "No file"}
|
||||
|
|
|
|||
|
|
@ -19,15 +19,15 @@ export default function InputGlobalComponent({
|
|||
editNode = false,
|
||||
}: InputGlobalComponentType): JSX.Element {
|
||||
const globalVariablesEntries = useGlobalVariablesStore(
|
||||
(state) => state.globalVariablesEntries
|
||||
(state) => state.globalVariablesEntries,
|
||||
);
|
||||
|
||||
const getVariableId = useGlobalVariablesStore((state) => state.getVariableId);
|
||||
const unavaliableFields = useGlobalVariablesStore(
|
||||
(state) => state.unavaliableFields
|
||||
(state) => state.unavaliableFields,
|
||||
);
|
||||
const removeGlobalVariable = useGlobalVariablesStore(
|
||||
(state) => state.removeGlobalVariable
|
||||
(state) => state.removeGlobalVariable,
|
||||
);
|
||||
const setErrorData = useAlertStore((state) => state.setErrorData);
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ export default function InputGlobalComponent({
|
|||
data.node?.template[name].load_from_db
|
||||
) {
|
||||
setTimeout(() => {
|
||||
onChange("");
|
||||
onChange("", true);
|
||||
setDb(false);
|
||||
}, 100);
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ export default function InputGlobalComponent({
|
|||
<ForwardedIconComponent
|
||||
name="Trash2"
|
||||
className={cn(
|
||||
"h-4 w-4 text-primary opacity-0 hover:text-status-red group-hover:opacity-100"
|
||||
"h-4 w-4 text-primary opacity-0 hover:text-status-red group-hover:opacity-100",
|
||||
)}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
|
|
@ -146,8 +146,8 @@ export default function InputGlobalComponent({
|
|||
onChange(value);
|
||||
setDb(value !== "" ? true : false);
|
||||
}}
|
||||
onChange={(value) => {
|
||||
onChange(value);
|
||||
onChange={(value, skipSnapshot) => {
|
||||
onChange(value, skipSnapshot);
|
||||
setDb(false);
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export default function IntComponent({
|
|||
// Clear component state
|
||||
useEffect(() => {
|
||||
if (disabled && value !== "") {
|
||||
onChange("");
|
||||
onChange("", true);
|
||||
}
|
||||
}, [disabled, onChange]);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export default function PromptAreaComponent({
|
|||
}: PromptAreaComponentType): JSX.Element {
|
||||
useEffect(() => {
|
||||
if (disabled && value !== "") {
|
||||
onChange("");
|
||||
onChange("", true);
|
||||
}
|
||||
}, [disabled]);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export default function TextAreaComponent({
|
|||
// Clear text area
|
||||
useEffect(() => {
|
||||
if (disabled && value !== "") {
|
||||
onChange("");
|
||||
onChange("", true);
|
||||
}
|
||||
}, [disabled]);
|
||||
|
||||
|
|
|
|||
|
|
@ -159,11 +159,12 @@ export default function ParameterComponent({
|
|||
|
||||
const handleOnNewValue = async (
|
||||
newValue: string | string[] | boolean | Object[],
|
||||
skipSnapshot: boolean | undefined = false,
|
||||
): Promise<void> => {
|
||||
const nodeTemplate = data.node!.template[name];
|
||||
const currentValue = nodeTemplate.value;
|
||||
|
||||
if (currentValue !== newValue) {
|
||||
if (currentValue !== newValue && !skipSnapshot) {
|
||||
takeSnapshot();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export type InputComponentType = {
|
|||
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
||||
value?: string;
|
||||
disabled?: boolean;
|
||||
onChange?: (value: string) => void;
|
||||
onChange?: (value: string, snapshot?: boolean) => void;
|
||||
password: boolean;
|
||||
required?: boolean;
|
||||
isForm?: boolean;
|
||||
|
|
@ -100,7 +100,7 @@ export type TextAreaComponentType = {
|
|||
nodeClass?: APIClassType;
|
||||
setNodeClass?: (value: APIClassType) => void;
|
||||
disabled: boolean;
|
||||
onChange: (value: string[] | string) => void;
|
||||
onChange: (value: string[] | string, skipSnapshot?: boolean) => void;
|
||||
value: string;
|
||||
editNode?: boolean;
|
||||
id?: string;
|
||||
|
|
@ -112,7 +112,7 @@ export type PromptAreaComponentType = {
|
|||
nodeClass?: APIClassType;
|
||||
setNodeClass?: (value: APIClassType, code?: string) => void;
|
||||
disabled: boolean;
|
||||
onChange: (value: string[] | string) => void;
|
||||
onChange: (value: string[] | string, skipSnapshot?: boolean) => void;
|
||||
value: string;
|
||||
readonly?: boolean;
|
||||
editNode?: boolean;
|
||||
|
|
@ -122,7 +122,7 @@ export type PromptAreaComponentType = {
|
|||
export type CodeAreaComponentType = {
|
||||
setOpenModal?: (bool: boolean) => void;
|
||||
disabled: boolean;
|
||||
onChange: (value: string[] | string) => void;
|
||||
onChange: (value: string[] | string, skipSnapshot?: boolean) => void;
|
||||
value: string;
|
||||
editNode?: boolean;
|
||||
nodeClass?: APIClassType;
|
||||
|
|
@ -137,7 +137,7 @@ export type CodeAreaComponentType = {
|
|||
export type FileComponentType = {
|
||||
IOInputProps?;
|
||||
disabled: boolean;
|
||||
onChange: (value: string[] | string) => void;
|
||||
onChange: (value: string[] | string, skipSnapshot?: boolean) => void;
|
||||
value: string;
|
||||
fileTypes: Array<string>;
|
||||
onFileChange: (value: string) => void;
|
||||
|
|
@ -170,7 +170,7 @@ export type IntComponentType = {
|
|||
value: string;
|
||||
disabled?: boolean;
|
||||
rangeSpec: RangeSpecType;
|
||||
onChange: (value: string) => void;
|
||||
onChange: (value: string, skipSnapshot?: boolean) => void;
|
||||
editNode?: boolean;
|
||||
id?: string;
|
||||
};
|
||||
|
|
@ -178,7 +178,7 @@ export type IntComponentType = {
|
|||
export type FloatComponentType = {
|
||||
value: string;
|
||||
disabled?: boolean;
|
||||
onChange: (value: string) => void;
|
||||
onChange: (value: string, skipSnapshot?: boolean) => void;
|
||||
rangeSpec: RangeSpecType;
|
||||
editNode?: boolean;
|
||||
id?: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue