Skip to content

Commit 7022e8d

Browse files
authored
fix[devtools/extension]: fixed duplicating panels in firefox (#27320)
Multiple `chrome.panels.create` calls result into having duplicate panels created in Firefox, these changes fix that. Now calling `chrome.panels.create` only if there are no panels created yet.
1 parent b70a0d7 commit 7022e8d

File tree

1 file changed

+18
-0
lines changed
  • packages/react-devtools-extensions/src/main

1 file changed

+18
-0
lines changed

packages/react-devtools-extensions/src/main/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,16 +340,24 @@ function ensureInitialHTMLIsCleared(container) {
340340

341341
function createComponentsPanel() {
342342
if (componentsPortalContainer) {
343+
// Panel is created and user opened it at least once
343344
render('components');
344345

345346
return;
346347
}
347348

349+
if (componentsPanel) {
350+
// Panel is created, but wasn't opened yet, so no document is present for it
351+
return;
352+
}
353+
348354
chrome.devtools.panels.create(
349355
IS_CHROME || IS_EDGE ? '⚛️ Components' : 'Components',
350356
IS_EDGE ? 'icons/production.svg' : '',
351357
'panel.html',
352358
createdPanel => {
359+
componentsPanel = createdPanel;
360+
353361
createdPanel.onShown.addListener(portal => {
354362
componentsPortalContainer = portal.container;
355363
if (componentsPortalContainer != null) {
@@ -370,16 +378,24 @@ function createComponentsPanel() {
370378

371379
function createProfilerPanel() {
372380
if (profilerPortalContainer) {
381+
// Panel is created and user opened it at least once
373382
render('profiler');
374383

375384
return;
376385
}
377386

387+
if (profilerPanel) {
388+
// Panel is created, but wasn't opened yet, so no document is present for it
389+
return;
390+
}
391+
378392
chrome.devtools.panels.create(
379393
IS_CHROME || IS_EDGE ? '⚛️ Profiler' : 'Profiler',
380394
IS_EDGE ? 'icons/production.svg' : '',
381395
'panel.html',
382396
createdPanel => {
397+
profilerPanel = createdPanel;
398+
383399
createdPanel.onShown.addListener(portal => {
384400
profilerPortalContainer = portal.container;
385401
if (profilerPortalContainer != null) {
@@ -510,6 +526,8 @@ let store = null;
510526

511527
let profilingData = null;
512528

529+
let componentsPanel = null;
530+
let profilerPanel = null;
513531
let componentsPortalContainer = null;
514532
let profilerPortalContainer = null;
515533

0 commit comments

Comments
 (0)