Skip to content

Commit

Permalink
fix: skip mid-touch contextmenu event
Browse files Browse the repository at this point in the history
  • Loading branch information
gfxholo committed Jun 20, 2024
1 parent 6a613a4 commit 0329a82
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/BookmarkIconManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import IconPicker from './IconPicker';
*/
export default class BookmarkIconManager extends IconManager {
private containerEl: HTMLElement;
private isTouchActive = false;
private readonly selectionLookup = new Map<HTMLElement, BookmarkItem>();

constructor(plugin: IconicPlugin) {
Expand Down Expand Up @@ -127,7 +128,15 @@ export default class BookmarkIconManager extends IconManager {
const selfEl = itemEl.find(':scope > .tree-item-self');
if (selfEl) {
this.selectionLookup.set(selfEl, bmark);
this.setEventListener(selfEl, 'contextmenu', () => this.onContextMenu(bmark.id, bmark.isFile), { capture: true });
this.setEventListener(selfEl, 'touchstart', () => this.isTouchActive = true);
this.setEventListener(selfEl, 'contextmenu', () => {
// Mobile fires this event twice on bookmarks, so skip the mid-touch event
if (this.isTouchActive) {
this.isTouchActive = false;
} else {
this.onContextMenu(bmark.id, bmark.isFile);
}
}, { capture: true });
}
};
}
Expand Down

0 comments on commit 0329a82

Please sign in to comment.