Commit 72feadce authored by Phil Hughes's avatar Phil Hughes

Merge branch '55344-only-prompt-user-once-when-navigating-away-from-file-editor' into 'master'

Resolve "Only prompt user once when navigating away from file editor"

Closes #55344

See merge request gitlab-org/gitlab-ce!23820
parents 91855866 5ee5203d
...@@ -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