Fix the type of variables added from the drop-down menu (#8725)

This commit is contained in:
D8H
2026-06-16 12:50:14 +02:00
committed by GitHub
parent f6872bd7a1
commit c5c1901d38
@@ -331,20 +331,6 @@ export default (React.forwardRef<Props, VariableFieldInterface>(
[updateAutocompletions]
);
const isSwitchableInstruction =
instruction &&
gd.VariableInstructionSwitcher.isSwitchableVariableInstruction(
instruction.getType()
);
const variableType =
project && instruction && isSwitchableInstruction
? gd.VariableInstructionSwitcher.getVariableTypeFromParameters(
project.getCurrentPlatform(),
projectScopedContainersAccessor.get(),
instruction
)
: null;
const openVariableEditor = React.useCallback(
() => {
if (!onOpenDialog) {
@@ -362,10 +348,16 @@ export default (React.forwardRef<Props, VariableFieldInterface>(
shouldCreate:
!!fieldCurrentValue &&
!isRootVariableDeclared(fieldCurrentValue, variablesContainers),
variableType: getVariableTypeName(variableType),
variableType: instruction
? getVariableTypeName(
gd.VariableInstructionSwitcher.getSwitchableInstructionVariableType(
instruction.getType()
)
)
: 'number',
});
},
[onChange, onOpenDialog, value, variableType, variablesContainers]
[instruction, onChange, onOpenDialog, value, variablesContainers]
);
const openParameterEditor = React.useCallback(
@@ -386,7 +378,13 @@ export default (React.forwardRef<Props, VariableFieldInterface>(
fieldCurrentValue,
variablesContainers
),
variableType: getVariableTypeName(variableType),
variableType: instruction
? getVariableTypeName(
gd.VariableInstructionSwitcher.getSwitchableInstructionVariableType(
instruction.getType()
)
)
: 'number',
});
},
[
@@ -394,7 +392,7 @@ export default (React.forwardRef<Props, VariableFieldInterface>(
value,
onChange,
variablesContainers,
variableType,
instruction,
]
);
@@ -465,6 +463,20 @@ export default (React.forwardRef<Props, VariableFieldInterface>(
? t`This variable has the same name as an object. Consider renaming one or the other.`
: null;
const isSwitchableInstruction =
instruction &&
gd.VariableInstructionSwitcher.isSwitchableVariableInstruction(
instruction.getType()
);
const variableType =
project && instruction && isSwitchableInstruction
? gd.VariableInstructionSwitcher.getVariableTypeFromParameters(
project.getCurrentPlatform(),
projectScopedContainersAccessor.get(),
instruction
)
: null;
const needManualTypeSwitcher =
isSwitchableInstruction &&
variableType !== gd.Variable.Number &&