chrome.sidePanel.open

1,617 views
Skip to first unread message

Patricio Gonzalez

unread,
Aug 16, 2023, 9:55:31 AM8/16/23
to Chromium Extensions
I was just waiting to have Chrome 116 to use it, but now i have, it seems like didn't work.
there is a type definition to use typescript with this?
why is associated with a tab id, I thought the side panel was independent of that

wOxxOm

unread,
Aug 16, 2023, 10:27:10 AM8/16/23
to Chromium Extensions, Patricio Gonzalez
It works in Chrome 116. You don't have to specify tabId, if you specify windowId. For type definitions, use the official package (it's chrome-types, not @types/chrome).

Stefan Van Damme

unread,
Aug 16, 2023, 4:22:41 PM8/16/23
to Chromium Extensions, Patricio Gonzalez
Hi Patricio,

If you want a tutorial on how to create a Chrome sidePanel and include a Chrome Web Store extension in my developer article, you can check out the "Note Sidebar" Chrome extension.
https://www.stefanvd.net/blog/2023/05/06/how-to-create-a-sidebar-chrome-extension-mv3/

Thanks,
Stefan vd

Patricio Gonzalez

unread,
Aug 17, 2023, 9:25:56 AM8/17/23
to Chromium Extensions, Stefan Van Damme, Patricio Gonzalez
Thank you, Steffan. Finally the code works as a charm to open the sidebar in the popup, and the services worker was this
```
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs.length > 0) {
const tabId = tabs[0].id;
chrome.sidePanel.open({ tabId });
}
});

i couldn't find the API to close the sidepanel although

Oliver Dunk

unread,
Aug 17, 2023, 9:27:55 AM8/17/23
to Patricio Gonzalez, Chromium Extensions, Stefan Van Damme
There's no API to close the side panel from the background, but you can send a message to it and use window.close().

Hope that helps!
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/f70cf75b-4bae-46e6-94e6-dd222aa345een%40chromium.org.

Patricio Gonzalez

unread,
Aug 17, 2023, 9:28:48 AM8/17/23
to Chromium Extensions, Oliver Dunk, Chromium Extensions, Stefan Van Damme, Patricio Gonzalez
Yes, that is very helpful, I will do that, thanks!!

Stefan Van Damme

unread,
Aug 17, 2023, 9:29:27 AM8/17/23
to Chromium Extensions, Patricio Gonzalez, Stefan Van Damme
Hi Patricio,

|| Thank you, Steffan. Finally the code works as a charm to open the sidebar in the popup, and the services worker was this
Great to hear this! You are welcome.

Thanks,
Reply all
Reply to author
Forward
0 new messages