From d6c9ce84ea904faa34966335a028a2a29051abd2 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Tue, 2 Jul 2019 21:28:40 +0200 Subject: [PATCH] delay frontend init if not focused (fixes #1147, fixes #1137) --- .../src/components/splitTab.component.ts | 12 +++++++++--- .../src/api/baseTerminalTab.component.ts | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/terminus-core/src/components/splitTab.component.ts b/terminus-core/src/components/splitTab.component.ts index a13aaa3b..71582de2 100644 --- a/terminus-core/src/components/splitTab.component.ts +++ b/terminus-core/src/components/splitTab.component.ts @@ -189,7 +189,11 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes this.focused$.subscribe(() => { this.getAllTabs().forEach(x => x.emitFocused()) - this.focus(this.focusedTab) + if (this.focusedTab) { + this.focus(this.focusedTab) + } else { + this.focusAnyIn(this.root) + } }) this.blurred$.subscribe(() => this.getAllTabs().forEach(x => x.emitBlurred())) @@ -235,8 +239,10 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes await this.recoverContainer(this.root, this._recoveredState) this.layout() setImmediate(() => { - this.getAllTabs().forEach(x => x.emitFocused()) - this.focusAnyIn(this.root) + if (this.hasFocus) { + this.getAllTabs().forEach(x => x.emitFocused()) + this.focusAnyIn(this.root) + } }) } } diff --git a/terminus-terminal/src/api/baseTerminalTab.component.ts b/terminus-terminal/src/api/baseTerminalTab.component.ts index 435e4f3f..ef5739d2 100644 --- a/terminus-terminal/src/api/baseTerminalTab.component.ts +++ b/terminus-terminal/src/api/baseTerminalTab.component.ts @@ -174,15 +174,17 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit this.session.releaseInitialDataBuffer() }) - this.frontend.configure() - - if (this.hasFocus) { - this.frontend.attach(this.content.nativeElement) - } else { - this.focused$.pipe(first()).subscribe(() => { + setImmediate(() => { + if (this.hasFocus) { this.frontend.attach(this.content.nativeElement) - }) - } + this.frontend.configure() + } else { + this.focused$.pipe(first()).subscribe(() => { + this.frontend.attach(this.content.nativeElement) + this.frontend.configure() + }) + } + }) this.attachTermContainerHandlers()