From 85fe9eb4ecf91ec431c067055936f61acb3e5a9c Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Tue, 27 Jul 2021 20:27:03 +0200 Subject: [PATCH] don't show drop hints when dragging the tab onto itself --- tabby-core/src/components/splitTab.component.ts | 1 + .../src/components/splitTabDropZone.component.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tabby-core/src/components/splitTab.component.ts b/tabby-core/src/components/splitTab.component.ts index 43aa88e0..7482310c 100644 --- a/tabby-core/src/components/splitTab.component.ts +++ b/tabby-core/src/components/splitTab.component.ts @@ -147,6 +147,7 @@ export interface SplitDropZoneInfo { > diff --git a/tabby-core/src/components/splitTabDropZone.component.ts b/tabby-core/src/components/splitTabDropZone.component.ts index f2621d0d..f784acee 100644 --- a/tabby-core/src/components/splitTabDropZone.component.ts +++ b/tabby-core/src/components/splitTabDropZone.component.ts @@ -22,6 +22,7 @@ import { SplitDropZoneInfo } from './splitTab.component' }) export class SplitTabDropZoneComponent extends SelfPositioningComponent { @Input() dropZone: SplitDropZoneInfo + @Input() parent: BaseTabComponent @Output() tabDropped = new EventEmitter() @HostBinding('class.active') isActive = false @HostBinding('class.highlighted') isHighlighted = false @@ -32,8 +33,8 @@ export class SplitTabDropZoneComponent extends SelfPositioningComponent { app: AppService, ) { super(element) - this.subscribeUntilDestroyed(app.tabDragActive$, active => { - this.isActive = active + this.subscribeUntilDestroyed(app.tabDragActive$, tab => { + this.isActive = !!tab && tab !== this.parent this.layout() }) } @@ -43,7 +44,12 @@ export class SplitTabDropZoneComponent extends SelfPositioningComponent { } layout () { - const tabElement: HTMLElement = this.dropZone.relativeToTab.viewContainerEmbeddedRef?.rootNodes[0] + const tabElement: HTMLElement|undefined = this.dropZone.relativeToTab.viewContainerEmbeddedRef?.rootNodes[0] + + if (!tabElement) { + // being destroyed + return + } const args = { t: [0, 0, tabElement.clientWidth, tabElement.clientHeight / 5],