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

Add onbeforeunload and have it call onCancel #7335

Merged
merged 6 commits into from
Nov 6, 2019
Merged

Add onbeforeunload and have it call onCancel #7335

merged 6 commits into from
Nov 6, 2019

Conversation

rickycodes
Copy link
Contributor

@rickycodes rickycodes commented Oct 31, 2019

re: #6489

this makes it so the same RPC error that fires when you cancel will also fire when you close the window.

Copy link
Contributor

@whymarrh whymarrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick: can we move componentWillUnmount below componentDidMount? (We (c|s)hould have a lint rule maybe)

@Gudahtt
Copy link
Member

Gudahtt commented Oct 31, 2019

Incidentally, the e2e test failure may have been fixed in the PR I just merged today. I would suggest rebasing on latest develop.

@whymarrh
Copy link
Contributor

I'll wait for the build to pass before approving but this LGTM

@Gudahtt
Copy link
Member

Gudahtt commented Oct 31, 2019

Darn, I guess it didn't fix it after all 😞

I was thinking that one of the calls to closeAllWindowHandlesExcept was causing this issue, and I had removed a few. One of the remaining ones might be the culprit though.

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, one difference I just noticed between this and the other beforeunload handlers is that the others record a separate metric event for this scenario, rather than reusing the same function as for the cancel button. That would probably be better to do in this case as well.

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, this behavior should be restricted to the notification UI. I don't think we want closing a fullscreen tab or the popup UI to constitute a rejection (especially not the popup UI, given that it closes when your mouse moves away)

@danjm
Copy link
Contributor

danjm commented Nov 5, 2019

Good point @Gudahtt

@rickycodes See how I restricted this to the notification window in this PR: https://github.com/MetaMask/metamask-extension/pull/6340/files

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing approval until above comment address, just to prevent accidental merger

@rickycodes
Copy link
Contributor Author

rickycodes commented Nov 5, 2019

@danjm @Gudahtt I added the ENVIRONMENT_TYPE_NOTIFICATION check.. didn't seem necessary to check for the removeEventListener since those will just return undefined if the event listener hasn't been added

let me know if this needs anything else

danjm
danjm previously approved these changes Nov 5, 2019
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@whymarrh whymarrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @rickycodes!

@rickycodes rickycodes merged commit 02aebc2 into MetaMask:develop Nov 6, 2019
Gudahtt added a commit that referenced this pull request Nov 13, 2019
This was first implemented in #7335, but the final version didn't work
because the `_beforeUnload` handler was not bound early, so `this` was
not defined when it was triggered.
Gudahtt added a commit that referenced this pull request Nov 13, 2019
This was first implemented in #7335, but the final version didn't work
because the `_beforeUnload` handler was not bound early, so `this` was
not defined when it was triggered.
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.

4 participants