From 45c549f550e0e04f43c70f242cea4c4378819b52 Mon Sep 17 00:00:00 2001 From: PJ Date: Thu, 24 Nov 2022 00:54:27 -0500 Subject: [PATCH] Keep hover editors from closing when mouse moves If the mouse recently opened a hover editor and you left it there, Quick Explorer would open hover previews and then immediately close them. This version fixes that issue and generally prevents mouse movements from affecting hover editors opened by Quick Explorer. --- manifest.json | 2 +- src/FolderMenu.ts | 7 +++++-- versions.json | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index d380084..edb60dc 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "Quick Explorer", "author": "PJ Eby", "authorUrl": "https://github.com/pjeby", - "version": "0.2.4", + "version": "0.2.5", "description": "Perform file explorer operations (and see your current file path) from the title bar, using the mouse or keyboard", "minAppVersion": "0.15.9", "isDesktopOnly": true diff --git a/src/FolderMenu.ts b/src/FolderMenu.ts index 3ab37a5..f33dd74 100644 --- a/src/FolderMenu.ts +++ b/src/FolderMenu.ts @@ -11,6 +11,7 @@ declare module "obsidian" { position(pos?: {x: number, y: number}): void hide(): void onHover: boolean + onTarget: boolean isPinned?: boolean abortController?: Component targetEl?: HTMLElement @@ -370,8 +371,8 @@ export class FolderMenu extends PopupMenu implements HoverParent { if (popover === old) return; if (old && popover !== old) { this._popover = null; - old.onHover = false; // Force unpinned Hover Editors to close - if (!old.isPinned) old.hide(); + old.onHover = old.onTarget = false; // Force unpinned Hover Editors to close + if (!old.isPinned || autoPreview) old.hide(); } if (popover && !this.canShowPopover()) { popover.onHover = false; // Force unpinned Hover Editors to close @@ -416,6 +417,8 @@ export class FolderMenu extends PopupMenu implements HoverParent { popover.position({x: left, y: top}); hoverEl.style.top = top + "px"; hoverEl.style.left = left + "px"; + // Keep hover editor from closing even if mouse moves away + popover.togglePin?.(true); } if ("onShowCallback" in popover) { around(popover as any, {onShowCallback(old) { diff --git a/versions.json b/versions.json index 155bbca..d5b4441 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "0.2.4": "0.15.9", + "0.2.5": "0.15.9", "0.1.41": "0.15.9", "0.1.37": "0.14.5", "0.1.23": "0.14.2",