electron-about-window icon indicating copy to clipboard operation
electron-about-window copied to clipboard

Calling openAboutWindow multiple times presents multiple about windows

Open BillyRayPreachersSon opened this issue 4 years ago • 1 comments

I'm using electron:^16.0.5, about-window:^1.15.2, and running on Mac OS Big Sur 11.6.1.

Wiring up a call to openAboutWindow from my About context menu item's click handler, the About window opens as expected when the menu item is chosen.

However, if the menu item is chosen again before the About window is closed, multiple About windows will be presented.

Is it possible to show the first window if it is still present?

{
  label: 'About',
  click: () => openAboutWindow({
    ...
  }),
},

BillyRayPreachersSon avatar Dec 22 '21 15:12 BillyRayPreachersSon

For the moment, I've worked around this by keeping track of the About window, but it would be nice to not have this extra code. Perhaps if multiple windows are desirable, make this configurable?

let aboutWindow = null;

function closeAboutWindow() {
  aboutWindow.off('close', closeAboutWindow);
  aboutWindow = null;
}

function openSingleAboutWindow() {
  if (aboutWindow) {
    aboutWindow.show();
  } else {
    aboutWindow = openAboutWindow({
      ...
    });
    aboutWindow.on('close', closeAboutWindow);
  }
}

...

{
  label: 'About',
  click: openSingleAboutWindow,
},

BillyRayPreachersSon avatar Dec 22 '21 15:12 BillyRayPreachersSon