Open SpaceK33z opened 2 months ago
In contrast, when the side panel is opening, the focus remains on main webpage and does not move to the side panel, which makes some functions impossible. For example, a typical user requirement is to focus on the input box when the side panel opens, so that the user can input something immediately.
So I hope there is a way to solve the problem of bidirectional focus movement.
We discussed this during an in-person triage meeting at TPAC. We are aligned on the following:
We are supportive of implementing a tabs.focus() method which would return focus to the web content. This would close the popup if open and move focus away from other parts of the UI such as the address bar.
A typical case comes to mind. When opening a new tab page(by shortcut or mouse), the focus is on the address bar for user input. Now the new tab page extension would like to call tabs.focus() to move the focus into the NTP for its own searching or shortcut function. Do browsers allow this behavior?
There may be other risks of abuse.
I raised that exact question and the answer is that the content area would be focused indeed. The meeting notes for the TPAC 2024 meeting will be published soon, here is the relevant excerpt:
Any movement on this?
Description: Interacting with the extension’s side panel (
chrome.sidePanel
) shifts focus away from the main webpage, and there is no way to programmatically return focus to the main document. This limitation makes it impossible to implement some features related to accessibility.Context: Managing focus between the main document and the side panel's document within the same tab is essential for accessibility. With proper focus management, the user can select something from the side panel, and the side panel can simulate certain events that only work when the main document is in focus.
Currently, extensions can switch focus between tabs, but not within the main document and side panel document.
Proposed Solution: Introduce a new API that allows extensions to programmatically shift focus from the side panel back to the main document.