Feature Request / Guidance: Native sidePanel.toggle() or extended user gesture for sidePanel.open()

21 views
Skip to first unread message

Hitesh230

unread,
3:48 AM (4 hours ago) 3:48 AM
to Chromium Extensions

Hi Chrome Extensions Team,

I am developing a productivity extension (WaVault) and I'm trying to implement a keyboard shortcut to toggle the side panel using the chrome.commands and chrome.sidePanel APIs.

The Problem: > There is currently no native sidePanel.toggle() method. To implement a toggle manually, I must first check the current state (using chrome.runtime.getContexts). However, because getContexts is asynchronous, the "User Gesture" from the keyboard command often expires before I can call sidePanel.open(). This results in the error: "sidePanel.open() may only be called in response to a user gesture."

Even a single await for chrome.windows.getCurrent() or chrome.tabs.query() can consume the gesture.

My Questions:

  1. Is there a "recommended" way to toggle the panel that preserves the user gesture across the necessary async state checks?

  2. Are there plans to add _execute_side_panel as a standard command ID in manifest.json that supports toggling (similar to how _execute_action works)?

  3. Is the sidePanel.toggle() method (referenced in Chromium Issue 482108261) currently on the roadmap for a stable release?

Currently, the only workaround is to never use await, which limits logic, or to use a global variable to track state—which is unreliable due to Service Worker termination.

woxxom

unread,
4:14 AM (3 hours ago) 4:14 AM
to Chromium Extensions, Hitesh230
A possible workaround:

chrome.runtime.sendMessage('closeSidePanel');
chrome.sidePanel.open();

The side panel's script will listen to 'closeSidePanel' and call setTimeout(window.close,50) if it was open so that sidePanel.open() will be handled while the panel is still open and thus it'll do nothing, then window.close() will close the panel. Conversely, if the panel wasn't open, the message will be ignored and the panel will just open.


Reply all
Reply to author
Forward
0 new messages