-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opening SidePanel with tabId Results in Global SidePanel #987
Comments
I added the following code to see the relationship between tabId and sidePanel
As I moved between tabs that console printed the following.
|
hey there, were you able to resolve this? I'm having the same issue and it looks like the documentation says that this behavior is somehow expected.
|
@eboraks Have you tried removing the default side panel declaration in the manifest?
|
This works, thank you @AmySteam! |
For other users who might land here, if you have code that looks similar to this:
And are receiving this error:
Make sure you're calling
To fix, remove
|
@ehynds Thanks, it's indeed working. However, the type definitions seem a bit off for |
If I do that, this won't work:
Still surprised how complicated it is to just set a sidepanel to stay active on the initial tab 🤦♂️ |
Tried this too:
To no avail, @ehynds do you see anything wrong from what I'm trying to achieve? :D |
@belthaZornv, you should be able to use That will also allow you to remove the |
oops, what a blonde moment that is. hahaha! let me try with that! |
Cleaned up the code - still opening on all tabs though lol!
|
Yeah, this seems to be the behavior today. I don't remember off the top of my head if that was intentional - I'll try to follow-up on #1179. |
Thanks @oliverdunk, appreciate it 🙏 |
I have it working using this
|
Wow, I can't believe how long it took to figure this out! 😄 -- Here's what finally worked for me after spending the whole day on it :D function openSidePanel(windowId, tabId, scope) {
const sidePanelPath = 'sidepanel/sidepanel.htmll';
const options = {
path: sidePanelPath,
enabled: true,
...(tabId !== undefined ? { tabId } : { windowId })
};
if (scope === 'tab-specific' && tabId !== undefined) {
chrome.sidePanel.setOptions(options, () => {
chrome.sidePanel.open({ tabId });
});
} else {
chrome.sidePanel.setOptions({ path: sidePanelPath, enabled: true }, () => {
chrome.sidePanel.open({ windowId });
});
}
} and in the Manifest file remove this: "side_panel": {
"default_path": "sidepanel/sidepanel.html"
}, finally, if you made any edits to the scope you must reload the extension |
@Mohamed3nan, this workaround worked for me! It seems like the issue comes down to the thing in the manifest. unfortunately however using CC: #1179 |
Chrome Version
Version 117.0.5901.0 (Official Build) canary (64-bit)
Use Case
This is about an extension that summarizes text from a webpage. When the user clicks the action button, the background script opens a side panel to display the summarized text. To accomplish this, I want the side panel to appear only after the action button is clicked and only for the tabs where the action button was clicked.
Describe the bug
When opening a side-panel and setting the option to use tabId, I expect that the sidePanel will be limited to the tab. But, that isn't the case.
According to the docs
When using sidePanel.open(), you must choose the context in which it should open. Use windowId to open a global side panel. Alternatively, set the tabId to open the side panel only on a specific tab.
background.js
manifest
To Reproduce
Expected behavior
Since the tab was open with tabId the expected behavior is for the side panel to close when moving between tabs.
The text was updated successfully, but these errors were encountered: