Skip to content

Fix side panel open sample ordering - #1695

Open
KirtiRamchandani wants to merge 1 commit into
GoogleChrome:mainfrom
KirtiRamchandani:fix/sidepanel-open-preconfigure
Open

KirtiRamchandani wants to merge 1 commit into
GoogleChrome:mainfrom
KirtiRamchandani:fix/sidepanel-open-preconfigure

Conversation

@KirtiRamchandani

@KirtiRamchandani KirtiRamchandani commented Jun 1, 2026

Copy link
Copy Markdown

Fixes #1477.

Problem

The cookbook.sidepanel-open sample opened the tab-specific side panel before setting the tab-specific path. On the first click, Chrome showed the default side panel page; only a second click showed sidepanel-tab.html.

Root cause

chrome.sidePanel.open() must run during the user gesture, but the sample configured chrome.sidePanel.setOptions() after opening the panel. Reversing those calls inside the click handler would lose the user gesture before open() runs.

Solution

Preconfigure the tab-specific side panel path before the button is enabled or appended to the page. The click handlers now only call chrome.sidePanel.open(), so the first click opens the intended side panel page while preserving the user gesture requirement.

Tests

  • npx eslint functional-samples/cookbook.sidepanel-open/content-script.js functional-samples/cookbook.sidepanel-open/script.js functional-samples/cookbook.sidepanel-open/service-worker.js
  • npx prettier --check functional-samples/cookbook.sidepanel-open/README.md functional-samples/cookbook.sidepanel-open/content-script.js functional-samples/cookbook.sidepanel-open/script.js functional-samples/cookbook.sidepanel-open/service-worker.js
  • Node smoke check that the injected button is only appended after tab-specific setup and the extension page button is gated by setup
  • git diff --check origin/main..HEAD

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

Successfully merging this pull request may close these issues.

cookbook.sidepanel-open sample does not behave correctly

1 participant