Remove beforeunload listener for cancel button
This commit is contained in:
parent
07e079e8dd
commit
5ee5203d60
|
@ -17,6 +17,11 @@ export default () => {
|
|||
const currentAction = $('.js-file-title').data('currentAction');
|
||||
const projectId = editBlobForm.data('project-id');
|
||||
const commitButton = $('.js-commit-button');
|
||||
const cancelLink = $('.btn.btn-cancel');
|
||||
|
||||
cancelLink.on('click', () => {
|
||||
window.onbeforeunload = null;
|
||||
});
|
||||
|
||||
commitButton.on('click', () => {
|
||||
window.onbeforeunload = null;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
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', () => {
|
|||
setFixtures(`
|
||||
<div class="js-edit-blob-form">
|
||||
<button class="js-commit-button"></button>
|
||||
<a class="btn btn-cancel" href="#"></a>
|
||||
</div>`);
|
||||
blobBundle();
|
||||
});
|
||||
|
@ -27,4 +28,10 @@ describe('EditBlob', () => {
|
|||
|
||||
expect(window.onbeforeunload).toBeNull();
|
||||
});
|
||||
|
||||
it('removes beforeunload listener when cancel link is clicked', () => {
|
||||
$('.btn.btn-cancel').click();
|
||||
|
||||
expect(window.onbeforeunload).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue