@@ -20,11 +20,9 @@ async function tryOnEditContent(e) {
20
20
const rawContent = segment . querySelector ( '.raw-content' ) ;
21
21
22
22
let comboMarkdownEditor : ComboMarkdownEditor ;
23
- let form : HTMLFormElement ;
24
23
25
24
const cancelAndReset = ( e ) => {
26
25
e . preventDefault ( ) ;
27
- form . classList . add ( 'ignore-dirty' ) ;
28
26
showElem ( renderContent ) ;
29
27
hideElem ( editContentZone ) ;
30
28
comboMarkdownEditor . dropzoneReloadFiles ( ) ;
@@ -51,8 +49,7 @@ async function tryOnEditContent(e) {
51
49
showErrorToast ( data . errorMessage ) ;
52
50
return ;
53
51
}
54
- form . classList . remove ( 'ignore-dirty' ) ; // the form is no longer dirty
55
- reinitializeAreYouSure ( form ) ;
52
+ reinitializeAreYouSure ( editContentZone . querySelector ( 'form' ) ) ; // the form is no longer dirty
56
53
editContentZone . setAttribute ( 'data-content-version' , data . contentVersion ) ;
57
54
if ( ! data . content ) {
58
55
renderContent . innerHTML = document . querySelector ( '#no-content' ) . innerHTML ;
@@ -91,7 +88,7 @@ async function tryOnEditContent(e) {
91
88
comboMarkdownEditor = getComboMarkdownEditor ( editContentZone . querySelector ( '.combo-markdown-editor' ) ) ;
92
89
if ( ! comboMarkdownEditor ) {
93
90
editContentZone . innerHTML = document . querySelector ( '#issue-comment-editor-template' ) . innerHTML ;
94
- form = editContentZone . querySelector ( 'form' ) ;
91
+ const form = editContentZone . querySelector ( 'form' ) ;
95
92
applyAreYouSure ( form ) ;
96
93
const saveButton = querySingleVisibleElem < HTMLButtonElement > ( editContentZone , '.ui.primary.button' ) ;
97
94
const cancelButton = querySingleVisibleElem < HTMLButtonElement > ( editContentZone , '.ui.cancel.button' ) ;
@@ -100,9 +97,6 @@ async function tryOnEditContent(e) {
100
97
comboMarkdownEditor . container . addEventListener ( ComboMarkdownEditor . EventUploadStateChanged , syncUiState ) ;
101
98
cancelButton . addEventListener ( 'click' , cancelAndReset ) ;
102
99
form . addEventListener ( 'submit' , saveAndRefresh ) ;
103
- } else {
104
- form = editContentZone . querySelector ( 'form' ) ;
105
- form . classList . remove ( 'ignore-dirty' ) ; // the form is shown again, respect the "dirty" state
106
100
}
107
101
108
102
// FIXME: ideally here should reload content and attachment list from backend for existing editor, to avoid losing data
0 commit comments