Skip to content

Commit 63dede5

Browse files
Prevent wrong toolbar actions being shown when navigating tabs (#8268)
1 parent 70ac0d0 commit 63dede5

8 files changed

+56
-8
lines changed

newIDE/app/src/MainFrame/EditorContainers/CustomObjectEditorContainer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,13 @@ export class CustomObjectEditorContainer extends React.Component<RenderEditorCon
136136
}
137137

138138
updateToolbar() {
139-
if (this.editor) this.editor.updateToolbar();
139+
if (this.editor) {
140+
this.editor.updateToolbar();
141+
} else {
142+
// Clear the toolbar if the editor is not ready yet to avoid showing stale toolbar
143+
// from the previous editor (e.g., HomePage)
144+
this.props.setToolbar(null);
145+
}
140146
}
141147

142148
forceUpdateEditor() {

newIDE/app/src/MainFrame/EditorContainers/DebuggerEditorContainer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ export class DebuggerEditorContainer extends React.Component<
5050
}
5151

5252
updateToolbar() {
53-
if (this.editor) this.editor.updateToolbar();
53+
if (this.editor) {
54+
this.editor.updateToolbar();
55+
} else {
56+
// Clear the toolbar if the editor is not ready yet to avoid showing stale toolbar
57+
// from the previous editor (e.g., HomePage)
58+
this.props.setToolbar(null);
59+
}
5460
}
5561

5662
forceUpdateEditor() {

newIDE/app/src/MainFrame/EditorContainers/EventsEditorContainer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ export class EventsEditorContainer extends React.Component<RenderEditorContainer
5454
}
5555

5656
updateToolbar() {
57-
if (this.editor) this.editor.updateToolbar();
57+
if (this.editor) {
58+
this.editor.updateToolbar();
59+
} else {
60+
// Clear the toolbar if the editor is not ready yet to avoid showing stale toolbar
61+
// from the previous editor (e.g., HomePage)
62+
this.props.setToolbar(null);
63+
}
5864
}
5965

6066
forceUpdateEditor() {

newIDE/app/src/MainFrame/EditorContainers/EventsFunctionsExtensionEditorContainer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ export class EventsFunctionsExtensionEditorContainer extends React.Component<Ren
3939
}
4040

4141
updateToolbar() {
42-
if (this.editor) this.editor.updateToolbar();
42+
if (this.editor) {
43+
this.editor.updateToolbar();
44+
} else {
45+
// Clear the toolbar if the editor is not ready yet to avoid showing stale toolbar
46+
// from the previous editor (e.g., HomePage)
47+
this.props.setToolbar(null);
48+
}
4349
}
4450

4551
forceUpdateEditor() {

newIDE/app/src/MainFrame/EditorContainers/ExternalEventsEditorContainer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ export class ExternalEventsEditorContainer extends React.Component<
8484
}
8585

8686
updateToolbar() {
87-
if (this.editor) this.editor.updateToolbar();
87+
if (this.editor) {
88+
this.editor.updateToolbar();
89+
} else {
90+
// Clear the toolbar if the editor is not ready yet to avoid showing stale toolbar
91+
// from the previous editor (e.g., HomePage)
92+
this.props.setToolbar(null);
93+
}
8894
}
8995

9096
forceUpdateEditor() {

newIDE/app/src/MainFrame/EditorContainers/ExternalLayoutEditorContainer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ export class ExternalLayoutEditorContainer extends React.Component<
154154
}
155155

156156
updateToolbar() {
157-
if (this.editor) this.editor.updateToolbar();
157+
if (this.editor) {
158+
this.editor.updateToolbar();
159+
} else {
160+
// Clear the toolbar if the editor is not ready yet to avoid showing stale toolbar
161+
// from the previous editor (e.g., HomePage when opening external layout from home page)
162+
this.props.setToolbar(null);
163+
}
158164
}
159165

160166
forceUpdateEditor() {

newIDE/app/src/MainFrame/EditorContainers/ResourcesEditorContainer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ export class ResourcesEditorContainer extends React.Component<RenderEditorContai
3434
}
3535

3636
updateToolbar() {
37-
if (this.editor) this.editor.updateToolbar();
37+
if (this.editor) {
38+
this.editor.updateToolbar();
39+
} else {
40+
// Clear the toolbar if the editor is not ready yet to avoid showing stale toolbar
41+
// from the previous editor (e.g., HomePage)
42+
this.props.setToolbar(null);
43+
}
3844
}
3945

4046
forceUpdateEditor() {

newIDE/app/src/MainFrame/EditorContainers/SceneEditorContainer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ export class SceneEditorContainer extends React.Component<RenderEditorContainerP
101101
}
102102

103103
updateToolbar() {
104-
if (this.editor) this.editor.updateToolbar();
104+
if (this.editor) {
105+
this.editor.updateToolbar();
106+
} else {
107+
// Clear the toolbar if the editor is not ready yet to avoid showing stale toolbar
108+
// from the previous editor (e.g., HomePage when opening scene from home page)
109+
this.props.setToolbar(null);
110+
}
105111
}
106112

107113
forceUpdateEditor() {

0 commit comments

Comments
 (0)