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

[Doc Update] Open the Side Panel when extension name or pinned icon is clicked #126

Open
ADTC opened this issue Aug 28, 2024 · 1 comment

Comments

@ADTC
Copy link

ADTC commented Aug 28, 2024

I have a Plasmo project which only has sidepanel.tsx and doesn't have popup.tsx. If I click on the extension icon (either pinned or from Extensions menu), nothing happens. I have to right-click the icon or open the overflow menu and choose "Open Side Panel" option to see the side panel.

Is there any way to open the side panel when the pinned extension icon is clicked or the extension name is clicked in the Extension menu instead of doing nothing?

@ADTC ADTC changed the title Open the Side Panel when extension name or pinned icon is clicked [Doc Update] Open the Side Panel when extension name or pinned icon is clicked Aug 28, 2024
@ADTC
Copy link
Author

ADTC commented Aug 28, 2024

I have the answer to this, so the issue is no longer "How do I do this?" but now it is "I know how. Please tell everyone else by adding it to the docs."

You have to have a background service worker, which is either background.ts or background/index.ts (or the equivalent .js file), which contains the following code:

chrome.sidePanel
  .setPanelBehavior({ openPanelOnActionClick: true })
  .catch((error) => console.error(error))

This will ensure the pinned icon or extension name will open the side panel when clicked. If it's clicked again, the side panel is closed, and you can click it again to open the side panel again. Behavior is as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant