Skip to content
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

sidePanel won't re-open after switch back #142

Open
Xheldon opened this issue Mar 23, 2024 · 8 comments
Open

sidePanel won't re-open after switch back #142

Xheldon opened this issue Mar 23, 2024 · 8 comments
Assignees
Labels
Bug the issue is a code defect that should be fixed Investigating The reported bug or issue is being actively investigated

Comments

@Xheldon
Copy link

Xheldon commented Mar 23, 2024

My extension has the same problem. After using the official example code, once the user switches to another tab, the sidebar disappears and it does not automatically open again when switching back.

So when I tried to reopen it using this interface, I got the following error(only in Edge):

Uncaught (in promise) Error: `sidePanel.open()` may only be called in response to a user gesture.

Here is my code in background.js:

chrome.tabs.onActivated.addListener(async (activeInfo) => {
    const tabId = activeInfo.tabId;
    const tab = await chrome.tabs.get(tabId);
    if (!tab.url) return;
    const url = new URL(tab.url);
    if (url.origin === 'https://www.notion.so') {
        await chrome.sidePanel.setOptions({
            tabId,
            path: 'sidepanel.html',
            enabled: true
        });
        // EDGE-ONLY: just edge browser has this problem, so I add this code blow, but I got the error and it's not work
        await chrome.sidePanel.open({
            tabId,
        });
    } else {
        // Disables the side panel on all other sites
        await chrome.sidePanel.setOptions({
            tabId,
            enabled: false
        });
    }
});

Please note, on Chrome, even without that piece of EDGE-ONLY code, it still works as expected: the sidebar automatically closes when switching to non-notion.so tabs, and the sidebar remains in its pre-switch open state when switching back to a notion.so tab.
However, on Edge, the sidebar will close when switching to a non-notion.so tab (as expected), but when switching back to a notion.so tab, the sidebar will not remain open, and it has to be manually reopened at this point.
Even if I add that EDGE-ONLY code, it still doesn't work and also throws an error.

@Gurjeet-msft Any idea?

Originally posted by @Xheldon in #95 (reply in thread)

@ManikanthMSFT
Copy link
Collaborator

Hi @Xheldon, we apologize for the inconvenience.

Could you please confirm if the issue is resolved?

@sivMSFT sivMSFT added Bug the issue is a code defect that should be fixed Investigating The reported bug or issue is being actively investigated labels Jun 5, 2024
@Xheldon
Copy link
Author

Xheldon commented Jun 5, 2024

@Manikanth2109 YES, the problem still exists. Version is: 125.0.2535.85 (Production) (arm64).

@ManikanthMSFT
Copy link
Collaborator

Thank you @Xheldon for the confirmation. We'll contact the right team responsible and get this fixed as soon as possible!

@zoulou00
Copy link

Hello,
Do you have any updates on the timeline for the resolution? 😊

@ManikanthMSFT
Copy link
Collaborator

@zoulou00, thank you for reaching out. We understand your eagerness for an update. Please be assured that our team is diligently working on the issue.

Once we have more information or an update on the timeline for resolution, we will promptly write back to you. Your understanding and patience are appreciated.

@rishikramena-ms
Copy link

rishikramena-ms commented Jul 4, 2024

Hi @zoulou00,
The part where you add the Edge only code to reopen the closed side panel, it throws the mentioned error ( sidePanel.open() may only be called in response to a user gesture.) because the sidePanel.open() is supposed to be called only in response to a user gesture which is not triggered in this case. Here the sidePanel.open() is being called on tab activation which is not considered a user interaction. Ref: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/developer-guide/sidebar#opening-the-sidebar-upon-user-interaction

Now coming to your original problem, that the side panel does not reopen automatically on switching tabs. This is because the behavior is specified to disable the side panel on all other sites. So when you navigate to other sites, the side side panel which was open on 'notion' will get closed automatically. When you switch back to the notion tab, the side panel does not open automatically as it is specified for Edge by design. But since the behavior is specified to be enabled on this tab, so this will allow opening the side panel from the context menu entry or the side panel open button on the extensions menu.

We are discussing internally to allow the enabled side panel to remain open on the tab it was previously open. But until then, a user interaction is needed to reopen the side panel even in the enabled sites.

You can also explore setting the side panel behavior not attached to a tabId which would allow you to enable the side panel on all tabs. This won't close the side panel when you change tabs. Ref: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/developer-guide/sidebar#display-the-same-sidebar-on-every-site

@thryyy
Copy link

thryyy commented Jul 10, 2024

Hi @rishikramena-ms

Thank you for your explanation. I now understand that the sidepanel is attached to the window rather than to each tab, which clarifies the behavior I was observing.

However, I'd like to point out that this behavior differs from Chrome, where the sidepanel reopens if it was already open for a specific tab (I'm guessing they're bypassing the user interraction rule internally). As an extension developer, one of the exciting aspects of Edge being based on Chromium was the ability to develop for both browsers without requiring browser-specific code. I'm concerned that these diverging behaviors might lead us back to the challenges we faced before this convergence.

Another difference I've noticed is that in Edge, the sidepanel width resets each time it's closed, whereas in Chrome, it's saved for the entire session until the browser is closed.

Thank you for considering this feedback.

@iNick
Copy link

iNick commented Jul 19, 2024

I want to emphasize what @thryyy wrote above. The different design for how Edge handles side panels (shared for all tabs in a window) compared to Chrome (unique per tab) is also causing us a lot of headaches and extra work.

I also found this discussion pointing out the inconsistencies in the implementations of the sidePanel API: w3c/webextensions#588

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug the issue is a code defect that should be fixed Investigating The reported bug or issue is being actively investigated
Projects
None yet
Development

No branches or pull requests

7 participants