From 761e5590e92c2f6e1071ea1d78cbd3fb8b12cbad Mon Sep 17 00:00:00 2001 From: bitpshr Date: Tue, 27 Mar 2018 16:49:29 -0400 Subject: [PATCH] Only ever show one context menu at a time --- src/app/files/file-explorer.js | 8 ++++++-- src/app/ui/contextMenu.js | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index 92c9e7b203..dc862123fd 100644 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -10,6 +10,8 @@ var helper = require('../../lib/helper') var css = require('./styles/file-explorer-styles') +let MENU_HANDLE + function fileExplorer (appAPI, files) { var self = this this.events = new EventManager() @@ -119,7 +121,8 @@ function fileExplorer (appAPI, files) { }) self.treeView.event.register('nodeRightClick', function (key, data, label, event) { - contextMenu(event, { + MENU_HANDLE && MENU_HANDLE.hide(null, true) + MENU_HANDLE = contextMenu(event, { 'Rename': () => { if (self.files.readonly) { return addTooltip('cannot rename folder. ' + self.files.type + ' is a read only explorer') } var name = label.querySelector('label[data-path="' + key + '"]') @@ -133,7 +136,8 @@ function fileExplorer (appAPI, files) { }) self.treeView.event.register('leafRightClick', function (key, data, label, event) { - contextMenu(event, { + MENU_HANDLE && MENU_HANDLE.hide(null, true) + MENU_HANDLE = contextMenu(event, { 'Rename': () => { if (self.files.readonly) { return addTooltip('cannot rename file. ' + self.files.type + ' is a read only explorer') } var name = label.querySelector('label[data-path="' + key + '"]') diff --git a/src/app/ui/contextMenu.js b/src/app/ui/contextMenu.js index 39a7072cf3..cbd1bf0ac2 100644 --- a/src/app/ui/contextMenu.js +++ b/src/app/ui/contextMenu.js @@ -65,4 +65,6 @@ module.exports = (event, items) => { setTimeout(() => { window.addEventListener('click', hide) }, 500) + + return { hide } }