diff --git a/src/renderer/components/_atoms/graphical-editor/fbd/autocomplete/index.tsx b/src/renderer/components/_atoms/graphical-editor/fbd/autocomplete/index.tsx index 11013763a..07d3db619 100644 --- a/src/renderer/components/_atoms/graphical-editor/fbd/autocomplete/index.tsx +++ b/src/renderer/components/_atoms/graphical-editor/fbd/autocomplete/index.tsx @@ -4,6 +4,7 @@ import { useOpenPLCStore } from '@root/renderer/store' import { extractNumberAtEnd } from '@root/renderer/store/slices/project/validation/variables' import { PLCVariable } from '@root/types/PLC' import { cn } from '@root/utils' +import { getLiteralType } from '@root/utils/keywords' import { newGraphicalEditorNodeID } from '@root/utils/new-graphical-editor-node-id' import { expandArrayVariables } from '@root/utils/PLC/array-variable-utils' import { Node } from '@xyflow/react' @@ -241,6 +242,7 @@ const FBDBlockAutoComplete = forwardRef { if (variable.id === 'add') { + if (getLiteralType(valueToSearch)) return submitAddVariable({ variableName: valueToSearch }) return } diff --git a/src/renderer/components/_atoms/graphical-editor/ladder/autocomplete/index.tsx b/src/renderer/components/_atoms/graphical-editor/ladder/autocomplete/index.tsx index 1b516811c..c7475b0fb 100644 --- a/src/renderer/components/_atoms/graphical-editor/ladder/autocomplete/index.tsx +++ b/src/renderer/components/_atoms/graphical-editor/ladder/autocomplete/index.tsx @@ -3,6 +3,7 @@ import { useOpenPLCStore } from '@root/renderer/store' import { extractNumberAtEnd } from '@root/renderer/store/slices/project/validation/variables' import { PLCVariable } from '@root/types/PLC' import { cn } from '@root/utils' +import { getLiteralType } from '@root/utils/keywords' import { expandArrayVariables } from '@root/utils/PLC/array-variable-utils' import { Node } from '@xyflow/react' import { ComponentPropsWithRef, forwardRef } from 'react' @@ -212,6 +213,7 @@ const VariablesBlockAutoComplete = forwardRef { if (variable.id === 'add') { + if (getLiteralType(valueToSearch)) return submitAddVariable({ variableName: valueToSearch }) return } diff --git a/src/renderer/components/_atoms/graphical-editor/ladder/coil.tsx b/src/renderer/components/_atoms/graphical-editor/ladder/coil.tsx index 68838595d..bb05640ab 100644 --- a/src/renderer/components/_atoms/graphical-editor/ladder/coil.tsx +++ b/src/renderer/components/_atoms/graphical-editor/ladder/coil.tsx @@ -10,6 +10,7 @@ import { } from '@root/renderer/assets/icons/flow/Coil' import { useOpenPLCStore } from '@root/renderer/store' import { cn, generateNumericUUID } from '@root/utils' +import { getLiteralType } from '@root/utils/keywords' import type { Node, NodeProps } from '@xyflow/react' import { Position } from '@xyflow/react' import type { ReactNode } from 'react' @@ -476,7 +477,8 @@ export const Coil = (block: CoilProps) => { // Call triggerSubmit synchronously before blur to avoid race condition // where autocomplete unmounts before processing the Enter key autocompleteRef.current?.triggerSubmit?.() - inputVariableRef.current?.blur({ submit: false }) + // For literals/constants, let the blur handler process them + inputVariableRef.current?.blur({ submit: !!getLiteralType(coilVariableValue) }) return } setKeyPressedAtTextarea(e.key) diff --git a/src/renderer/components/_atoms/graphical-editor/ladder/contact.tsx b/src/renderer/components/_atoms/graphical-editor/ladder/contact.tsx index e58925c47..cdb4f21ce 100644 --- a/src/renderer/components/_atoms/graphical-editor/ladder/contact.tsx +++ b/src/renderer/components/_atoms/graphical-editor/ladder/contact.tsx @@ -8,6 +8,7 @@ import { } from '@root/renderer/assets/icons/flow/Contact' import { useOpenPLCStore } from '@root/renderer/store' import { cn, generateNumericUUID } from '@root/utils' +import { getLiteralType } from '@root/utils/keywords' import type { Node, NodeProps } from '@xyflow/react' import { Position } from '@xyflow/react' import type { ReactNode } from 'react' @@ -446,7 +447,8 @@ export const Contact = (block: ContactProps) => { // Call triggerSubmit synchronously before blur to avoid race condition // where autocomplete unmounts before processing the Enter key autocompleteRef.current?.triggerSubmit?.() - inputVariableRef.current?.blur({ submit: false }) + // For literals/constants, let the blur handler process them + inputVariableRef.current?.blur({ submit: !!getLiteralType(contactVariableValue) }) return } setKeyPressedAtTextarea(e.key) diff --git a/src/renderer/components/_atoms/graphical-editor/ladder/variable.tsx b/src/renderer/components/_atoms/graphical-editor/ladder/variable.tsx index c4b5cbf6d..c225171eb 100644 --- a/src/renderer/components/_atoms/graphical-editor/ladder/variable.tsx +++ b/src/renderer/components/_atoms/graphical-editor/ladder/variable.tsx @@ -498,7 +498,9 @@ const VariableElement = (block: VariableProps) => { // Call triggerSubmit synchronously before blur to avoid race condition // where autocomplete unmounts before processing the Enter key autocompleteRef.current?.triggerSubmit?.() - inputVariableRef.current?.blur({ submit: false }) + // For literals/constants, let the blur handler process them + // instead of suppressing it (triggerSubmit skips variable creation for literals) + inputVariableRef.current?.blur({ submit: !!getLiteralType(variableValue) }) return } setKeyPressedAtTextarea(e.key)