From 0b33a5ca9318d909233914adb0cbd90d3bc7a472 Mon Sep 17 00:00:00 2001 From: Nishikant Parmar Date: Sat, 7 Oct 2023 16:14:36 +0530 Subject: [PATCH] Hide completer when changing notebook tabs (#14534) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change mousedown event to pointerdown to hide the widget when there are other mousedown events with preventDefault and stopPropogation * Remove debug statements --------- Co-authored-by: root Co-authored-by: MichaƂ Krassowski <5832902+krassowski@users.noreply.github.com> --- packages/completer/src/widget.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/completer/src/widget.ts b/packages/completer/src/widget.ts index b0bf78be40ff..5a2acd452b94 100644 --- a/packages/completer/src/widget.ts +++ b/packages/completer/src/widget.ts @@ -207,8 +207,8 @@ export class Completer extends Widget { case 'keydown': this._evtKeydown(event as KeyboardEvent); break; - case 'mousedown': - this._evtMousedown(event as MouseEvent); + case 'pointerdown': + this._evtPointerdown(event as PointerEvent); break; case 'scroll': this._evtScroll(event as MouseEvent); @@ -251,7 +251,7 @@ export class Completer extends Widget { */ protected onAfterAttach(msg: Message): void { document.addEventListener('keydown', this, USE_CAPTURE); - document.addEventListener('mousedown', this, USE_CAPTURE); + document.addEventListener('pointerdown', this, USE_CAPTURE); document.addEventListener('scroll', this, USE_CAPTURE); } @@ -260,7 +260,7 @@ export class Completer extends Widget { */ protected onBeforeDetach(msg: Message): void { document.removeEventListener('keydown', this, USE_CAPTURE); - document.removeEventListener('mousedown', this, USE_CAPTURE); + document.removeEventListener('pointerdown', this, USE_CAPTURE); document.removeEventListener('scroll', this, USE_CAPTURE); } @@ -653,7 +653,7 @@ export class Completer extends Widget { /** * Handle mousedown events for the widget. */ - private _evtMousedown(event: MouseEvent) { + private _evtPointerdown(event: PointerEvent) { if (this.isHidden || !this._editor) { return; }