> I was trying to do window.close, but it also closing other sidepanels which are opened in other tabs
Since the same code runs in all side panels, you need to add a
condition to close the one you want. For example, if it's tabId of
the associated tab, you can pass it as a parameter when creating
the panel:
chrome.sidePanel.setOptions({tabId, enabled: true, path:
'sidepanel.html?tabId=' + tabId});
Then it'll be available inside the panel:
const myTabId = +new URLSearchParams(location.search).get('tabId');
Then in your message listener you'll compare this myTabId to the tabId in the message.
I am trying implement sidebar close for our extension and I noticed that as close api doesn't exist on sidepanel feature yet, trying for other approaches to close it.
For me, I want to open SidePanel for each tab independently which is working now (based on url/domain check), but during closing the side planel, I was using message bus to listen for close event in sidepanel.js
and I was trying to do window.close, but it also closing other sidepanels which are opened in other tabs
any suggestions?