From bbc4d68485eb2ccea92730193e45f93a03f5ecbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Tue, 7 Apr 2026 18:23:13 +0200 Subject: [PATCH 1/3] Fix "Add or edit variables" button opening scene variables instead of local variables --- .../ParameterFields/AnyVariableField.js | 63 +++++++++++++------ .../AnyVariableOrPropertyField.js | 63 +++++++++++++------ .../AnyVariableOrPropertyOrParameterField.js | 63 +++++++++++++------ 3 files changed, 132 insertions(+), 57 deletions(-) diff --git a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableField.js b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableField.js index 4e9aebaab27b..dcda3a418069 100644 --- a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableField.js +++ b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableField.js @@ -8,6 +8,7 @@ import VariableField, { type VariableDialogOpeningProps, } from './VariableField'; import GlobalAndSceneVariablesDialog from '../../VariablesList/GlobalAndSceneVariablesDialog'; +import LocalVariablesDialog from '../../VariablesList/LocalVariablesDialog'; import { type ParameterFieldProps, type ParameterFieldInterface, @@ -41,7 +42,6 @@ export default (React.forwardRef( onChange, value, } = props; - const { layout } = scope; const enumerateGlobalAndSceneVariables = React.useCallback( () => @@ -87,12 +87,18 @@ export default (React.forwardRef( [onChange, onInstructionTypeChanged, value] ); - const isGlobal = !!( - layout && - project && - !layout.getVariables().has(getRootVariableName(props.value)) && - project.getVariables().has(getRootVariableName(props.value)) + const variablesContainer = React.useMemo( + () => { + const variablesContainersList = projectScopedContainersAccessor + .get() + .getVariablesContainersList(); + return variablesContainersList.getVariablesContainerFromVariableNameOnly( + props.value + ); + }, + [projectScopedContainersAccessor, props.value] ); + const variableSourceType = variablesContainer.getSourceType(); return ( @@ -123,19 +129,38 @@ export default (React.forwardRef( onInstructionTypeChanged={onInstructionTypeChanged} getVariableSourceFromIdentifier={getVariableSourceFromIdentifier} /> - {editorOpen && ( - setEditorOpen(null)} - onApply={onVariableEditorApply} - isGlobalTabInitiallyOpen={isGlobal} - initiallySelectedVariableName={editorOpen.variableName} - shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} - hotReloadPreviewButtonProps={null} - isListLocked={false} - /> - )} + {editorOpen && + (variableSourceType === gd.VariablesContainer.Local ? ( + project && ( + setEditorOpen(null)} + onApply={onVariableEditorApply} + initiallySelectedVariableName={editorOpen.variableName} + shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} + isListLocked={false} + /> + ) + ) : ( + setEditorOpen(null)} + onApply={onVariableEditorApply} + isGlobalTabInitiallyOpen={ + variableSourceType === gd.VariablesContainer.Global + } + initiallySelectedVariableName={editorOpen.variableName} + shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} + hotReloadPreviewButtonProps={null} + isListLocked={false} + /> + ))} ); } diff --git a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js index ae51e41135ae..977947a3780d 100644 --- a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js +++ b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js @@ -8,6 +8,7 @@ import VariableField, { type VariableDialogOpeningProps, } from './VariableField'; import GlobalAndSceneVariablesDialog from '../../VariablesList/GlobalAndSceneVariablesDialog'; +import LocalVariablesDialog from '../../VariablesList/LocalVariablesDialog'; import { type ParameterFieldProps, type ParameterFieldInterface, @@ -41,7 +42,6 @@ export default (React.forwardRef( onChange, value, } = props; - const { layout } = scope; const enumerateGlobalAndSceneVariables = React.useCallback( () => @@ -85,12 +85,18 @@ export default (React.forwardRef( [onChange, onInstructionTypeChanged, value] ); - const isGlobal = !!( - layout && - project && - !layout.getVariables().has(getRootVariableName(props.value)) && - project.getVariables().has(getRootVariableName(props.value)) + const variablesContainer = React.useMemo( + () => { + const variablesContainersList = projectScopedContainersAccessor + .get() + .getVariablesContainersList(); + return variablesContainersList.getVariablesContainerFromVariableNameOnly( + props.value + ); + }, + [projectScopedContainersAccessor, props.value] ); + const variableSourceType = variablesContainer.getSourceType(); return ( @@ -121,19 +127,38 @@ export default (React.forwardRef( onInstructionTypeChanged={onInstructionTypeChanged} getVariableSourceFromIdentifier={getVariableSourceFromIdentifier} /> - {editorOpen && ( - setEditorOpen(null)} - onApply={onVariableEditorApply} - isGlobalTabInitiallyOpen={isGlobal} - initiallySelectedVariableName={editorOpen.variableName} - shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} - hotReloadPreviewButtonProps={null} - isListLocked={false} - /> - )} + {editorOpen && + (variableSourceType === gd.VariablesContainer.Local ? ( + project && ( + setEditorOpen(null)} + onApply={onVariableEditorApply} + initiallySelectedVariableName={editorOpen.variableName} + shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} + isListLocked={false} + /> + ) + ) : ( + setEditorOpen(null)} + onApply={onVariableEditorApply} + isGlobalTabInitiallyOpen={ + variableSourceType === gd.VariablesContainer.Global + } + initiallySelectedVariableName={editorOpen.variableName} + shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} + hotReloadPreviewButtonProps={null} + isListLocked={false} + /> + ))} ); } diff --git a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js index 02d49f0096a4..4abb2ffd25a4 100644 --- a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js +++ b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js @@ -8,6 +8,7 @@ import VariableField, { type VariableDialogOpeningProps, } from './VariableField'; import GlobalAndSceneVariablesDialog from '../../VariablesList/GlobalAndSceneVariablesDialog'; +import LocalVariablesDialog from '../../VariablesList/LocalVariablesDialog'; import { type ParameterFieldProps, type ParameterFieldInterface, @@ -41,7 +42,6 @@ export default (React.forwardRef( onChange, value, } = props; - const { layout } = scope; const enumerateGlobalAndSceneVariables = React.useCallback( () => @@ -81,12 +81,18 @@ export default (React.forwardRef( [onChange, onInstructionTypeChanged, value] ); - const isGlobal = !!( - layout && - project && - !layout.getVariables().has(getRootVariableName(props.value)) && - project.getVariables().has(getRootVariableName(props.value)) + const variablesContainer = React.useMemo( + () => { + const variablesContainersList = projectScopedContainersAccessor + .get() + .getVariablesContainersList(); + return variablesContainersList.getVariablesContainerFromVariableNameOnly( + props.value + ); + }, + [projectScopedContainersAccessor, props.value] ); + const variableSourceType = variablesContainer.getSourceType(); return ( @@ -117,19 +123,38 @@ export default (React.forwardRef( onInstructionTypeChanged={onInstructionTypeChanged} getVariableSourceFromIdentifier={getVariableSourceFromIdentifier} /> - {editorOpen && ( - setEditorOpen(null)} - onApply={onVariableEditorApply} - isGlobalTabInitiallyOpen={isGlobal} - initiallySelectedVariableName={editorOpen.variableName} - shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} - hotReloadPreviewButtonProps={null} - isListLocked={false} - /> - )} + {editorOpen && + (variableSourceType === gd.VariablesContainer.Local ? ( + project && ( + setEditorOpen(null)} + onApply={onVariableEditorApply} + initiallySelectedVariableName={editorOpen.variableName} + shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} + isListLocked={false} + /> + ) + ) : ( + setEditorOpen(null)} + onApply={onVariableEditorApply} + isGlobalTabInitiallyOpen={ + variableSourceType === gd.VariablesContainer.Global + } + initiallySelectedVariableName={editorOpen.variableName} + shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} + hotReloadPreviewButtonProps={null} + isListLocked={false} + /> + ))} ); } From 7602e33e31d7dace1207fa817a4694907a2d0a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Tue, 7 Apr 2026 18:41:23 +0200 Subject: [PATCH 2/3] Fix the tab for extension --- .../EventsSheet/ParameterFields/AnyVariableOrPropertyField.js | 3 ++- .../ParameterFields/AnyVariableOrPropertyOrParameterField.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js index 977947a3780d..23666b0c698a 100644 --- a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js +++ b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js @@ -151,7 +151,8 @@ export default (React.forwardRef( onCancel={() => setEditorOpen(null)} onApply={onVariableEditorApply} isGlobalTabInitiallyOpen={ - variableSourceType === gd.VariablesContainer.Global + variableSourceType === gd.VariablesContainer.Global || + variableSourceType === gd.VariablesContainer.ExtensionGlobal } initiallySelectedVariableName={editorOpen.variableName} shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} diff --git a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js index 4abb2ffd25a4..cc787a53b15d 100644 --- a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js +++ b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js @@ -147,7 +147,8 @@ export default (React.forwardRef( onCancel={() => setEditorOpen(null)} onApply={onVariableEditorApply} isGlobalTabInitiallyOpen={ - variableSourceType === gd.VariablesContainer.Global + variableSourceType === gd.VariablesContainer.Global || + variableSourceType === gd.VariablesContainer.ExtensionGlobal } initiallySelectedVariableName={editorOpen.variableName} shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate} From ee2f8d30bfc9bebf6e5ffa59c63f087cd3785af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Tue, 7 Apr 2026 19:23:13 +0200 Subject: [PATCH 3/3] Fix container search for extensions --- .../EventsSheet/ParameterFields/AnyVariableOrPropertyField.js | 2 +- .../ParameterFields/AnyVariableOrPropertyOrParameterField.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js index 23666b0c698a..19141b3c7444 100644 --- a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js +++ b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyField.js @@ -90,7 +90,7 @@ export default (React.forwardRef( const variablesContainersList = projectScopedContainersAccessor .get() .getVariablesContainersList(); - return variablesContainersList.getVariablesContainerFromVariableNameOnly( + return variablesContainersList.getVariablesContainerFromVariableOrPropertyName( props.value ); }, diff --git a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js index cc787a53b15d..665ff1736a31 100644 --- a/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js +++ b/newIDE/app/src/EventsSheet/ParameterFields/AnyVariableOrPropertyOrParameterField.js @@ -86,7 +86,7 @@ export default (React.forwardRef( const variablesContainersList = projectScopedContainersAccessor .get() .getVariablesContainersList(); - return variablesContainersList.getVariablesContainerFromVariableNameOnly( + return variablesContainersList.getVariablesContainerFromVariableOrPropertyOrParameterName( props.value ); },