Skip to content

Commit

Permalink
refresh variable flyout when a new variable is created (#10396)
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll authored Feb 24, 2025
1 parent ef3c69a commit 6f8fab8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions webapp/src/blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class Editor extends toolboxeditor.ToolboxEditor {
showCategories: boolean = true;
breakpointsByBlock: pxt.Map<number>; // Map block id --> breakpoint ID
breakpointsSet: number[]; // the IDs of the breakpoints set.
currentFlyoutKey: string;

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

if (ev.type === "var_create") {
if (this.currentFlyoutKey === "variables" && this.editor.getFlyout()?.isVisible()) {
// refresh the flyout when a new variable is created
this.showVariablesFlyout();
}
}

if ((ignoredChanges.indexOf(ev.type) === -1)
|| this.markIncomplete) {
this.changeCallback();
Expand Down Expand Up @@ -1696,6 +1704,7 @@ export class Editor extends toolboxeditor.ToolboxEditor {
}

private showFlyoutInternal_(xmlList: Element[], flyoutName: string = "default") {
this.currentFlyoutKey = flyoutName;
const flyout = this.editor.getFlyout() as pxtblockly.VerticalFlyout;
flyout.show(xmlList, flyoutName);
flyout.scrollToStart();
Expand Down

0 comments on commit 6f8fab8

Please sign in to comment.