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

onBlock is never called #152

Open
gnekoz opened this issue Feb 2, 2023 · 0 comments
Open

onBlock is never called #152

gnekoz opened this issue Feb 2, 2023 · 0 comments

Comments

@gnekoz
Copy link

gnekoz commented Feb 2, 2023

In case the browser settings block the opening of a new popup/tab an error is raised and the onBlock callback is never invoked.
The cause is the creation of the div right after the window creation:

    // Open a new window.
    this.window = window.open(url, name, toWindowFeatures(features))
    this.container = this.window.document.createElement('div')

In case of browser blocking the window opening this.window will be undefined and the second line will fail:

TypeError: Cannot read properties of null (reading 'document')
    at NewWindow.openChild (new-window.js:236:32)
    at NewWindow.componentDidMount (new-window.js:191:9)
    at commitLifeCycles (react-dom.development.js:20664:1)

Also the creation of the div element seems unnecessary since the container property will be set few lines below:

		if (this.window) {
			this.window.document.title = title;

			// Check if the container already exists as the window may have been already open
			this.container = this.window.document.getElementById('new-window-container');
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