Giter Site home page Giter Site logo

Comments (5)

AmySteam avatar AmySteam commented on May 23, 2024 3

@eboraks Have you tried removing the default side panel declaration in the manifest?

  "side_panel": {
    "default_path": "sidepanel/sidepanel.html"
  },

from chrome-extensions-samples.

ehynds avatar ehynds commented on May 23, 2024 2

For other users who might land here, if you have code that looks similar to this:

await chrome.sidePanel.setOptions({
  tabId,
  path: 'panel.html',
  enabled: true,
});

await chrome.sidePanel.open({
  tabId,
});

And are receiving this error:

Uncaught (in promise) Error: No active side panel for tabId

Make sure you're calling setOptions before open. After making that change, you might start experiencing this error:

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

To fix, remove await from the setOptions call. Final working code (for me anyway):

chrome.sidePanel.setOptions({
  tabId,
  path: 'panel.html',
  enabled: true,
});

await chrome.sidePanel.open({
  tabId,
});

from chrome-extensions-samples.

zakariaelh avatar zakariaelh commented on May 23, 2024 1

This works, thank you @AmySteam!

from chrome-extensions-samples.

eboraks avatar eboraks commented on May 23, 2024

I added the following code to see the relationship between tabId and sidePanel

chrome.tabs.onActivated.addListener(async ({ tabId }) => { const { path } = await chrome.sidePanel.getOptions({ tabId }) console.log('tabId: ' + tabId + ' path: ' + path) })

As I moved between tabs that console printed the following.

background.js:31 tabId: 1101905827 path: sidepanel/sidepanel.html
background.js:31 tabId: 1101905829 path: sidepanel/sidepanel.html
background.js:31 tabId: 1101905856 path: sidepanel/sidepanel.html

from chrome-extensions-samples.

zakariaelh avatar zakariaelh commented on May 23, 2024

hey there, were you able to resolve this? I'm having the same issue and it looks like the documentation says that this behavior is somehow expected.

The tab in which to open the side panel. If the corresponding tab has a tab-specific side panel, the panel will only be open for that tab. If there is not a tab-specific panel, the global panel will be open in the specified tab and any other tabs without a currently-open tab- specific panel. This will override any currently-active side panel (global or tab-specific) in the corresponding tab. At least one of this and windowId must be provided.

link

from chrome-extensions-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.