Skip to content

Commit

Permalink
Keep hover editors from closing when mouse moves
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pjeby committed Nov 24, 2022
1 parent 0f54e2e commit 45c549f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/FolderMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 45c549f

Please sign in to comment.