Skip to content

Commit 3a0b95b

Browse files
authored
keep the error list collapsed if collapsed by user (#11121)
1 parent d533ca8 commit 3a0b95b

4 files changed

Lines changed: 27 additions & 0 deletions

File tree

localtypings/pxteditor.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ declare namespace pxt.editor {
820820
simSerialActive?: boolean;
821821
deviceSerialActive?: boolean;
822822
errorListState?: ErrorListState;
823+
errorListCollapsedByUser?: boolean;
823824
screenshoting?: boolean;
824825
extensionsVisible?: boolean;
825826
isMultiplayerGame?: boolean; // Arcade: Does the current project contain multiplayer blocks?

webapp/src/blocks.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,8 @@ export class Editor extends toolboxeditor.ToolboxEditor {
10921092
<ErrorList
10931093
errors={this.errors}
10941094
onSizeChange={this.onErrorListResize}
1095+
collapsedByUser={this.parent.state.errorListCollapsedByUser}
1096+
onUserCollapse={this.setErrorListCollapsePreference}
10951097
getErrorHelp={this.getErrorHelp}
10961098
showLoginDialog={this.parent.showLoginDialog}
10971099
startDebugger={this.startDebugger}
@@ -1105,6 +1107,12 @@ export class Editor extends toolboxeditor.ToolboxEditor {
11051107
this.parent.fireResize();
11061108
}
11071109

1110+
protected setErrorListCollapsePreference = (collapsed: boolean) => {
1111+
this.parent.setState({
1112+
errorListCollapsedByUser: collapsed
1113+
});
1114+
}
1115+
11081116
onExceptionDetected(exception: pxsim.DebuggerBreakpointMessage) {
11091117
const displayInfo: ErrorDisplayInfo = this.getDisplayInfoForException(exception);
11101118
this.errors = [displayInfo];

webapp/src/errorList.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export interface ErrorListProps {
4444
continuationHash?: string,
4545
dialogMessages?: { signInMessage?: string; signUpMessage?: string }
4646
) => void;
47+
collapsedByUser?: boolean;
48+
onUserCollapse?: (collapsed: boolean) => void;
4749
}
4850

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

6668
componentDidUpdate(prevProps: Readonly<ErrorListProps>, prevState: Readonly<ErrorListState>, snapshot?: any): void {
69+
if (this.props.collapsedByUser) {
70+
return;
71+
}
72+
6773
// Auto-expand if there are new errors
6874
if (this.props.errors.length > 0 && this.state.isCollapsed) {
6975
let shouldExpand = this.props.errors.length > prevProps.errors.length;
@@ -192,6 +198,10 @@ export class ErrorList extends auth.Component<ErrorListProps, ErrorListState> {
192198
pxt.tickEvent('errorlist.collapse', null, { interactiveConsent: true })
193199
}
194200

201+
if (this.props.onUserCollapse) {
202+
this.props.onUserCollapse(!this.state.isCollapsed);
203+
}
204+
195205
this.setState({
196206
isCollapsed: !this.state.isCollapsed
197207
}, this.onDisplayStateChange);

webapp/src/monaco.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ export class Editor extends toolboxeditor.ToolboxEditor {
664664
{showErrorList && (
665665
<ErrorList
666666
onSizeChange={this.setErrorListState}
667+
collapsedByUser={this.parent.state.errorListCollapsedByUser}
668+
onUserCollapse={this.setErrorListCollapsePreference}
667669
errors={this.errors}
668670
startDebugger={this.startDebugger}
669671
getErrorHelp={this.getErrorHelp}
@@ -959,6 +961,12 @@ export class Editor extends toolboxeditor.ToolboxEditor {
959961
}
960962
}
961963

964+
protected setErrorListCollapsePreference = (collapsed: boolean) => {
965+
this.parent.setState({
966+
errorListCollapsedByUser: collapsed
967+
});
968+
}
969+
962970
prepare() {
963971
this.isReady = true
964972
}

0 commit comments

Comments
 (0)