From 1e1f111267ad82b3579b28a84691f50271d9a57f Mon Sep 17 00:00:00 2001 From: PalmerAL Date: Sun, 15 Sep 2024 11:39:33 -0500 Subject: [PATCH] fix dragging files onto tab bar --- js/navbar/tabBar.js | 17 +++++++++++++---- js/navbar/tabEditor.js | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/js/navbar/tabBar.js b/js/navbar/tabBar.js index 1ecb5075c..c162dfd8c 100644 --- a/js/navbar/tabBar.js +++ b/js/navbar/tabBar.js @@ -309,10 +309,19 @@ tabBar.container.addEventListener('dragover', e => e.preventDefault()) tabBar.container.addEventListener('drop', e => { e.preventDefault() var data = e.dataTransfer - require('browserUI.js').addTab(tabs.add({ - url: data.files[0] ? 'file://' + data.files[0].path : data.getData('text'), - private: tabs.get(tabs.getSelected()).private - }), { enterEditMode: false, openInBackground: !settings.get('openTabsInForeground') }) + var path = data.files[0] ? 'file://' + electron.webUtils.getPathForFile(data.files[0]) : data.getData('text') + if (!path) { + return + } + if (tabEditor.isShown || tabs.isEmpty()) { + webviews.update(tabs.getSelected(), path) + tabEditor.hide() + } else { + require('browserUI.js').addTab(tabs.add({ + url: path, + private: tabs.get(tabs.getSelected()).private + }), { enterEditMode: false, openInBackground: !settings.get('openTabsInForeground') }) + } }) module.exports = tabBar diff --git a/js/navbar/tabEditor.js b/js/navbar/tabEditor.js index 6a91b887b..aa14b8e70 100644 --- a/js/navbar/tabEditor.js +++ b/js/navbar/tabEditor.js @@ -10,6 +10,7 @@ const tabEditor = { container: document.getElementById('tab-editor'), input: document.getElementById('tab-editor-input'), star: null, + isShown: false, show: function (tabId, editingValue, showSearchbar) { /* Edit mode is not available in modal mode. */ if (modalMode.enabled()) { @@ -17,6 +18,7 @@ const tabEditor = { } tabEditor.container.hidden = false + tabEditor.isShown = true bookmarkStar.update(tabId, tabEditor.star) contentBlockingToggle.update(tabId, tabEditor.contentBlockingToggle) @@ -71,6 +73,7 @@ const tabEditor = { hide: function () { tabEditor.container.hidden = true tabEditor.container.removeAttribute('style') + tabEditor.isShown = false tabEditor.input.blur() searchbar.hide()