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
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ export class MonitorWidget extends ReactWidget {
(this.focusNode || this.node).focus();
}

protected override onAfterShow(msg: Message): void {
super.onAfterShow(msg);
this.update();
}

protected onFocusResolved = (element: HTMLElement | undefined) => {
if (this.closing || !this.isAttached) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class SerialMonitorOutput extends React.Component<
* Do not touch it. It is used to be able to "follow" the serial monitor log.
*/
protected toDisposeBeforeUnmount = new DisposableCollection();
private listRef: React.RefObject<any>;
private listRef: React.RefObject<List>;

constructor(props: Readonly<SerialMonitorOutput.Props>) {
super(props);
Expand All @@ -34,12 +34,10 @@ export class SerialMonitorOutput extends React.Component<
<List
className="serial-monitor-messages"
height={this.props.height}
itemData={
{
lines: this.state.lines,
timestamp: this.state.timestamp,
} as any
}
itemData={{
lines: this.state.lines,
timestamp: this.state.timestamp,
}}
itemCount={this.state.lines.length}
itemSize={18}
width={'100%'}
Expand All @@ -65,11 +63,13 @@ export class SerialMonitorOutput extends React.Component<
this.state.charCount
);
const [lines, charCount] = truncateLines(newLines, totalCharCount);
this.setState({
lines,
charCount,
});
this.scrollToBottom();
this.setState(
{
lines,
charCount,
},
() => this.scrollToBottom()
);
}),
this.props.clearConsoleEvent(() =>
this.setState({ lines: [], charCount: 0 })
Expand All @@ -91,11 +91,11 @@ export class SerialMonitorOutput extends React.Component<
this.toDisposeBeforeUnmount.dispose();
}

scrollToBottom = ((): void => {
private readonly scrollToBottom = () => {
if (this.listRef.current && this.props.monitorModel.autoscroll) {
this.listRef.current.scrollToItem(this.state.lines.length, 'end');
}
}).bind(this);
};
}

const _Row = ({
Expand Down