diff --git a/terminus-core/src/services/app.service.ts b/terminus-core/src/services/app.service.ts index 1dd90595..d748d9e1 100644 --- a/terminus-core/src/services/app.service.ts +++ b/terminus-core/src/services/app.service.ts @@ -105,7 +105,9 @@ export class AppService { this.activeTab = tab this.activeTabChange.next(tab) if (this.activeTab) { - this.activeTab.emitFocused() + setImmediate(() => { + this.activeTab.emitFocused() + }) this.hostApp.setTitle(this.activeTab.title) } } diff --git a/terminus-plugin-manager/src/components/pluginsSettingsTab.component.pug b/terminus-plugin-manager/src/components/pluginsSettingsTab.component.pug index e8866569..7929a1b6 100644 --- a/terminus-plugin-manager/src/components/pluginsSettingsTab.component.pug +++ b/terminus-plugin-manager/src/components/pluginsSettingsTab.component.pug @@ -65,7 +65,7 @@ div(*ngIf='npmInstalled') .input-group.mb-3 .input-group-prepend .input-group-text - i.fas.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='!availablePluginsReady') + i.fas.fa-fw.fa-circle-notch.fa-spin(*ngIf='!availablePluginsReady') i.fas.fa-fw.fa-search(*ngIf='availablePluginsReady') input.form-control( type='text', diff --git a/terminus-terminal/src/components/baseTerminalTab.component.ts b/terminus-terminal/src/components/baseTerminalTab.component.ts index 98e9cdbd..5f5e3036 100644 --- a/terminus-terminal/src/components/baseTerminalTab.component.ts +++ b/terminus-terminal/src/components/baseTerminalTab.component.ts @@ -145,7 +145,15 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit }) this.frontend.configure() - this.frontend.attach(this.content.nativeElement) + + if (this.hasFocus) { + this.frontend.attach(this.content.nativeElement) + } else { + this.focused$.pipe(first()).subscribe(() => { + this.frontend.attach(this.content.nativeElement) + }) + } + this.attachTermContainerHandlers() this.configure() diff --git a/terminus-terminal/src/frontends/xtermFrontend.ts b/terminus-terminal/src/frontends/xtermFrontend.ts index 96f7d256..2d2f1bd6 100644 --- a/terminus-terminal/src/frontends/xtermFrontend.ts +++ b/terminus-terminal/src/frontends/xtermFrontend.ts @@ -54,6 +54,14 @@ export class XTermFrontend extends Frontend { this.xtermCore._scrollToBottom = this.xtermCore.scrollToBottom.bind(this.xtermCore) this.xtermCore.scrollToBottom = () => null + + this.resizeHandler = () => { + try { + (this.xterm as any).fit() + } catch { + // tends to throw when element wasn't shown yet + } + } } attach (host: HTMLElement): void { @@ -61,7 +69,6 @@ export class XTermFrontend extends Frontend { this.ready.next(null) this.ready.complete() - this.resizeHandler = () => (this.xterm as any).fit() window.addEventListener('resize', this.resizeHandler) this.resizeHandler()