Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -241,6 +242,7 @@ const FBDBlockAutoComplete = forwardRef<HTMLDivElement, FBDBlockAutoCompleteProp

const submit = ({ variable }: { variable: { id: string; name: string } }) => {
if (variable.id === 'add') {
if (getLiteralType(valueToSearch)) return
submitAddVariable({ variableName: valueToSearch })
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -212,6 +213,7 @@ const VariablesBlockAutoComplete = forwardRef<HTMLDivElement, VariablesBlockAuto

const submit = ({ variable }: { variable: { id: string; name: string } }) => {
if (variable.id === 'add') {
if (getLiteralType(valueToSearch)) return
submitAddVariable({ variableName: valueToSearch })
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down