dessant / search-by-image

Browser extension for reverse image search, available for Chrome, Edge and Safari
https://apps.apple.com/us/app/search-by-image-for-safari/id1544552106
GNU General Public License v3.0
2.28k stars 200 forks source link

Open new tabs in the current Firefox container #182

Open Nerixyz opened 2 years ago

Nerixyz commented 2 years ago

System

Bug description

When searching for an image from a container-tab in Firefox through the context menu, the opened tab isn't opened in the container but in the "root" container (i.e. no container). This is because the tab created by searchEngine doesn't include the openerTabId.

Patch

Since this project doesn't allow PRs (?!), I'm posting the diff here. It's two lines that need to be edited in src/background/main.js.

diff --git a/src/background/main.js b/src/background/main.js
index 7f93be8..7cc80dd 100644
--- a/src/background/main.js
+++ b/src/background/main.js
@@ -503,7 +503,8 @@ async function searchEngine(session, search, image, imageId, tabActive) {
   const tab = await createTab({
     token,
     index: session.sourceTabIndex,
-    active: tabActive
+    active: tabActive,
+    openerTabId: session.sourceTabId,
   });
   const tabId = tab.id;
dessant commented 2 years ago

I've seen some bugs after openerTabId was added to Web Archives, and ended up removing it for the time being. One I remember was with Firefox and regular tabs: when you were searching on multiple engines at once and closed the tab of a search result, the focus would jump to the openerTabId tab instead of the next tab in the tab strip. An attempt was made to chain openerTabId among search results, but that of course also resulted in the active tab jumping around if the tabs were rearranged before closing.

I'll give it another go at some point, but it will take considerable time despite the small change, because we have to test a bunch of platforms and use cases.