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

[Bug]: Subclass of BrowserWindow missing from BrowserWindow.getAllWindows() #41785

Closed
3 tasks done
safris opened this issue Apr 6, 2024 · 1 comment · May be fixed by #41795
Closed
3 tasks done

[Bug]: Subclass of BrowserWindow missing from BrowserWindow.getAllWindows() #41785

safris opened this issue Apr 6, 2024 · 1 comment · May be fixed by #41795
Assignees
Labels
29-x-y bug 🪲 has-repro-comment Issue has repro in comments platform/all status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@safris
Copy link

safris commented Apr 6, 2024

Preflight Checklist

Electron Version

29.2.0

What operating system are you using?

macOS

Operating System Version

Sonoma 14.3.1

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

No response

Expected Behavior

In the following code, I declare a subclass of BrowserWindow by the name of CustomWindow.
Then, I instantiate a regular BrowserWindow, as well as a CustomWindow.
Both windows appear.
When I call BrowserWindow.getAllWindows().length, I expect 2 to be returned.

const { app, BrowserWindow } = require("electron");

class CustomWindow extends BrowserWindow {
  constructor(options) {
    super(options);
  }
}

app.on("ready", () => {
  const win1 = new BrowserWindow();
  const win2 = new CustomWindow();
  const expected = 2;
  const actual = BrowserWindow.getAllWindows().length;
  if (actual != expected)
    throw new Error("Assertion failed");
});

app.on("window-all-closed", () => app.quit());

Actual Behavior

When I call BrowserWindow.getAllWindows().length, 1 is returned.

Testcase Gist URL

No response

Additional Information

No response

@safris safris added the bug 🪲 label Apr 6, 2024
@codebytere codebytere self-assigned this Apr 8, 2024
@codebytere codebytere added platform/all status/confirmed A maintainer reproduced the bug or agreed with the feature 29-x-y has-repro-comment Issue has repro in comments labels Apr 8, 2024
@nornagon
Copy link
Member

We don't support subclassing BrowserWindow. This isn't guaranteed to work correctly, even if it happens to (apparently, somewhat) work today.

@nornagon nornagon closed this as not planned Won't fix, can't repro, duplicate, stale Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
29-x-y bug 🪲 has-repro-comment Issue has repro in comments platform/all status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
No open projects
Status: 👍 Does Not Block Stable
Development

Successfully merging a pull request may close this issue.

3 participants