fix: terminal now auto-scrolls on output (was missing AfterViewChecked)
This commit is contained in:
parent
f3da41da01
commit
b7d6c950cf
@ -1,4 +1,4 @@
|
||||
import { Component, ElementRef, ViewChild, AfterViewInit, signal } from '@angular/core';
|
||||
import { Component, ElementRef, ViewChild, AfterViewInit, AfterViewChecked, signal } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
@ -8,7 +8,7 @@ import { CommonModule } from '@angular/common';
|
||||
templateUrl: './terminal.component.html',
|
||||
styleUrl: './terminal.component.scss',
|
||||
})
|
||||
export class TerminalComponent implements AfterViewInit {
|
||||
export class TerminalComponent implements AfterViewInit, AfterViewChecked {
|
||||
@ViewChild('terminalBody') terminalBody!: ElementRef<HTMLDivElement>;
|
||||
@ViewChild('termInput') termInput!: ElementRef<HTMLInputElement>;
|
||||
|
||||
@ -96,6 +96,11 @@ export class TerminalComponent implements AfterViewInit {
|
||||
this.lines.update((l) => [...l, text]);
|
||||
}
|
||||
|
||||
/** Auto-scroll to bottom whenever the view updates. */
|
||||
ngAfterViewChecked(): void {
|
||||
this.scrollToBottom();
|
||||
}
|
||||
|
||||
/** Focus the input when the terminal is clicked. */
|
||||
onClick(): void {
|
||||
this.termInput?.nativeElement.focus();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user