Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refresh variable flyout when a new variable is created #10396

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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