Commit 5ee5203d authored by Sam Bigelow's avatar Sam Bigelow

Remove beforeunload listener for cancel button

parent 07e079e8
...@@ -17,6 +17,11 @@ export default () => { ...@@ -17,6 +17,11 @@ export default () => {
const currentAction = $('.js-file-title').data('currentAction'); const currentAction = $('.js-file-title').data('currentAction');
const projectId = editBlobForm.data('project-id'); const projectId = editBlobForm.data('project-id');
const commitButton = $('.js-commit-button'); const commitButton = $('.js-commit-button');
const cancelLink = $('.btn.btn-cancel');
cancelLink.on('click', () => {
window.onbeforeunload = null;
});
commitButton.on('click', () => { commitButton.on('click', () => {
window.onbeforeunload = null; window.onbeforeunload = null;
......
---
title: Only prompt user once when navigating away from file editor
merge_request: 23820
author: Sam Bigelow
type: fixed
...@@ -14,6 +14,7 @@ describe('EditBlob', () => { ...@@ -14,6 +14,7 @@ describe('EditBlob', () => {
setFixtures(` setFixtures(`
<div class="js-edit-blob-form"> <div class="js-edit-blob-form">
<button class="js-commit-button"></button> <button class="js-commit-button"></button>
<a class="btn btn-cancel" href="#"></a>
</div>`); </div>`);
blobBundle(); blobBundle();
}); });
...@@ -27,4 +28,10 @@ describe('EditBlob', () => { ...@@ -27,4 +28,10 @@ describe('EditBlob', () => {
expect(window.onbeforeunload).toBeNull(); expect(window.onbeforeunload).toBeNull();
}); });
it('removes beforeunload listener when cancel link is clicked', () => {
$('.btn.btn-cancel').click();
expect(window.onbeforeunload).toBeNull();
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment