Skip to content

Commit 6f8fab8

Browse files
authored
refresh variable flyout when a new variable is created (#10396)
1 parent ef3c69a commit 6f8fab8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

webapp/src/blocks.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class Editor extends toolboxeditor.ToolboxEditor {
6161
showCategories: boolean = true;
6262
breakpointsByBlock: pxt.Map<number>; // Map block id --> breakpoint ID
6363
breakpointsSet: number[]; // the IDs of the breakpoints set.
64+
currentFlyoutKey: string;
6465

6566
private errorChangesListeners: pxt.Map<(errors: pxtblockly.BlockDiagnostic[]) => void> = {};
6667
protected intersectionObserver: IntersectionObserver;
@@ -667,6 +668,13 @@ export class Editor extends toolboxeditor.ToolboxEditor {
667668
this.hideFlyout();
668669
}
669670

671+
if (ev.type === "var_create") {
672+
if (this.currentFlyoutKey === "variables" && this.editor.getFlyout()?.isVisible()) {
673+
// refresh the flyout when a new variable is created
674+
this.showVariablesFlyout();
675+
}
676+
}
677+
670678
if ((ignoredChanges.indexOf(ev.type) === -1)
671679
|| this.markIncomplete) {
672680
this.changeCallback();
@@ -1696,6 +1704,7 @@ export class Editor extends toolboxeditor.ToolboxEditor {
16961704
}
16971705

16981706
private showFlyoutInternal_(xmlList: Element[], flyoutName: string = "default") {
1707+
this.currentFlyoutKey = flyoutName;
16991708
const flyout = this.editor.getFlyout() as pxtblockly.VerticalFlyout;
17001709
flyout.show(xmlList, flyoutName);
17011710
flyout.scrollToStart();

0 commit comments

Comments
 (0)