Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions localtypings/pxteditor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ declare namespace pxt.editor {
simSerialActive?: boolean;
deviceSerialActive?: boolean;
errorListState?: ErrorListState;
errorListCollapsedByUser?: boolean;
screenshoting?: boolean;
extensionsVisible?: boolean;
isMultiplayerGame?: boolean; // Arcade: Does the current project contain multiplayer blocks?
Expand Down
8 changes: 8 additions & 0 deletions webapp/src/blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,8 @@ export class Editor extends toolboxeditor.ToolboxEditor {
<ErrorList
errors={this.errors}
onSizeChange={this.onErrorListResize}
collapsedByUser={this.parent.state.errorListCollapsedByUser}
onUserCollapse={this.setErrorListCollapsePreference}
getErrorHelp={this.getErrorHelp}
showLoginDialog={this.parent.showLoginDialog}
startDebugger={this.startDebugger}
Expand All @@ -1105,6 +1107,12 @@ export class Editor extends toolboxeditor.ToolboxEditor {
this.parent.fireResize();
}

protected setErrorListCollapsePreference = (collapsed: boolean) => {
this.parent.setState({
errorListCollapsedByUser: collapsed
});
}

onExceptionDetected(exception: pxsim.DebuggerBreakpointMessage) {
const displayInfo: ErrorDisplayInfo = this.getDisplayInfoForException(exception);
this.errors = [displayInfo];
Expand Down
10 changes: 10 additions & 0 deletions webapp/src/errorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export interface ErrorListProps {
continuationHash?: string,
dialogMessages?: { signInMessage?: string; signUpMessage?: string }
) => void;
collapsedByUser?: boolean;
onUserCollapse?: (collapsed: boolean) => void;
}

export interface ErrorListState {
Expand All @@ -64,6 +66,10 @@ export class ErrorList extends auth.Component<ErrorListProps, ErrorListState> {
}

componentDidUpdate(prevProps: Readonly<ErrorListProps>, prevState: Readonly<ErrorListState>, snapshot?: any): void {
if (this.props.collapsedByUser) {
return;
}

// Auto-expand if there are new errors
if (this.props.errors.length > 0 && this.state.isCollapsed) {
let shouldExpand = this.props.errors.length > prevProps.errors.length;
Expand Down Expand Up @@ -192,6 +198,10 @@ export class ErrorList extends auth.Component<ErrorListProps, ErrorListState> {
pxt.tickEvent('errorlist.collapse', null, { interactiveConsent: true })
}

if (this.props.onUserCollapse) {
this.props.onUserCollapse(!this.state.isCollapsed);
}

this.setState({
isCollapsed: !this.state.isCollapsed
}, this.onDisplayStateChange);
Expand Down
8 changes: 8 additions & 0 deletions webapp/src/monaco.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ export class Editor extends toolboxeditor.ToolboxEditor {
{showErrorList && (
<ErrorList
onSizeChange={this.setErrorListState}
collapsedByUser={this.parent.state.errorListCollapsedByUser}
onUserCollapse={this.setErrorListCollapsePreference}
errors={this.errors}
startDebugger={this.startDebugger}
getErrorHelp={this.getErrorHelp}
Expand Down Expand Up @@ -959,6 +961,12 @@ export class Editor extends toolboxeditor.ToolboxEditor {
}
}

protected setErrorListCollapsePreference = (collapsed: boolean) => {
this.parent.setState({
errorListCollapsedByUser: collapsed
});
}

prepare() {
this.isReady = true
}
Expand Down
Loading