-
Couldn't load subscription status.
- Fork 71
Proposal: close() Method for the sidePanel API #837
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All changes requested in this review are either internal styling consistency or GFM rendering fixes.
Developers can currently close the document in the sidebar or sidepanel ("sidebar" for simplicity) by calling There are times when it might make sense to diverge or to change existing behavior to also require a user activation, but I don't think this is such a case. As I see it, there's minimal risk to allowing an extension to close it's own sidebar, especially since both supporting browsers currently require user activation to open a sidebar. The main risk I see is that an extension might try to close a side panel right before a user clicks in order to cause the user to click something they didn't intend to in the main document, but I'm not sure how practical that kind of attack would be. At the moment I'm comfortable with not requiring user activation, but I'll defer to @Rob--W for a more official position. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one comment, but otherwise this seems like a good proposal.
|
@carlosjeurissen While preparing the proposal, I was not in favor of throwing an error when the side panel is already closed for the given context. To keep things simple, an error should only be thrown if the context is invalid. Otherwise, it should simply do nothing and resolve, indicating that the panel is already closed for that context. If the side panel is opened globally for a window and we try to close it for just one tab, it will close for all tabs in that window. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure to align on the behavior when both windowId and tabId are specified. Otherwise, LGTM.
|
Currently, the focus is on using "close" when the intention is to remove the side panel from the tab registry entirely. The concept of "hide"—making the side panel inactive but not removing it—could be considered for future enhancements.
What I thought was -
|
If If there is a global panel open, and you call close() with a @kiaraarose Do you have a preference from the Safari side? |
The sidePanel.close() method allows extensions to programmatically close the side panel for a specified tabId or windowId. Reference: w3c/webextensions#837 Bug: 403765214 Change-Id: I16b1c05869a1f4707bf107d4eff1d085235b906b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6638129 Reviewed-by: Devlin Cronin <[email protected]> Commit-Queue: Oliver Dunk <[email protected]> Reviewed-by: Oliver Dunk <[email protected]> Cr-Commit-Position: refs/heads/main@{#1499029}
I agree with @carlosjeurissen that the behavior of closing a global sidePanel for all tabs if both Update: For Safari, we agree that having the sidePanel close for all tabs in this scenario wouldn't be ideal. I think an error for this case is sufficient. |
Thanks for following up. To confirm:
Is that correct? Also, an additional question: If you try to open a side panel for a |
This proposal introduces a sidePanel.close() method (among work items for Summer of Code).
While not fully fleshed out, it outlines the core idea. Initial feedback is welcome. I would also like your thoughts on the need for a user gesture for this. #521 #chromium