diff --git a/src/lib/project-saver-hoc.jsx b/src/lib/project-saver-hoc.jsx index 0ddcd967fc20372e9644b30e3d6172aa401b9ee4..af66847a473f471e5093d7bc501c3d32945c59a4 100644 --- a/src/lib/project-saver-hoc.jsx +++ b/src/lib/project-saver-hoc.jsx @@ -50,7 +50,9 @@ const ProjectSaverHOC = function (WrappedComponent) { } componentWillMount () { if (typeof window === 'object') { - window.addEventListener('beforeunload', this.leavePageConfirm); + // Note: it might be better to use a listener instead of assigning onbeforeunload; + // but then it'd be hard to turn this listening off in our tests + window.onbeforeunload = () => this.leavePageConfirm; } } componentDidUpdate (prevProps) { @@ -92,7 +94,7 @@ const ProjectSaverHOC = function (WrappedComponent) { } componentWillUnmount () { this.clearAutoSaveTimeout(); - window.removeEventListener('beforeunload', this.leavePageConfirm); + window.onbeforeunload = undefined; // eslint-disable-line no-undefined } leavePageConfirm (e) { if (this.props.projectChanged) { diff --git a/test/integration/sounds.test.js b/test/integration/sounds.test.js index ca1a3d275d8271e63af5068659429d4b4a4cee7e..3877ada3f8fa90acb8e866418fcc5ff1425b516d 100644 --- a/test/integration/sounds.test.js +++ b/test/integration/sounds.test.js @@ -32,6 +32,7 @@ describe('Working with sounds', () => { // Delete the sound await rightClickText('Meow', scope.soundsTab); + await driver.sleep(500); // Wait a moment for context menu; only needed for local testing await clickText('delete', scope.soundsTab); // Add it back