Open fregante opened 5 months ago
The sidePanel api is a bit weird really! It's actually complicated to even react to the damn action icon on-click handler to toggle the sidebar. I've switched to using openPanelOnContextMenuClick, but it's not as versatile. But you can trigger it on ANY keyboard event?? What's the point
The sidePanel can be opened via
chrome.sidePanel.open()
but the API isn't symmetrical, there is no.close()
API.It would also be useful (maybe even more so) to just
.toggle()
the sidebar instead, using any trigger other than the action click, for example:menus.onClick
<button>
added on the pageAlternative to
chrome.sidePanel.close()
(✅ it works)As @dotproto pointed out, the sidebar can close itself via
window.close()
, so in other contexts you would have to set up messaging.You can also use
chrome.sidePanel.setOptions({enabled: false})
but that has undesired side effects (it removes it from the side panels list)Alternative to
chrome.sidePanel.toggle()
(⛔️ it doesn't work)This is more complicated because there's no easy way to determine whether the sidebar is open, so you'd have to add another listener and hope that this delay won't cause you to lose the user gesture permission: