Skip to content

Commit

Permalink
remove weird "$jscomp not defined" error, make creation dialog closin…
Browse files Browse the repository at this point in the history
…g more robust
  • Loading branch information
stoerr committed Oct 11, 2023
1 parent bc85213 commit b1adf59
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
1 change: 1 addition & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Tell ChatGPT when we expect HTML.
Announcement, Installation, Doc überarbeiten
Refactor Aprrox Markdown for HTML
AEM for content fragments?
Expand Down
22 changes: 15 additions & 7 deletions aem/ui.frontend/src/main/webpack/site/ContentCreationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,26 @@ class ContentCreationDialog {
/** Dialog submit: overwrite calling richtext editor / textarea in dialog */
onSubmit(event) {
console.log("ContentCreationDialog onSubmit", arguments);
const response = this.getResponse();
this.closeDialog(event);
// only after closing since dialog is now out of the way
if (typeof this.writebackCallback == 'function') {
this.writebackCallback(response);
try {
const response = this.getResponse();
this.closeDialog(event);
// only after closing since dialog is now out of the way
if (typeof this.writebackCallback == 'function') {
this.writebackCallback(response);
}
} catch (e) { // better than crashing the whole page
console.error("Error in onSubmit", e);
}
}

/** Dialog cancel: just closes dialog. */
onCancel(event) {
console.log("ContentCreationDialog onCancel", arguments);
this.closeDialog(event);
try {
console.log("ContentCreationDialog onCancel", arguments);
this.closeDialog(event);
} catch (e) { // better than crashing the whole page
console.error("Error in onCancel", e);
}
}

closeDialog(event) {
Expand Down
25 changes: 2 additions & 23 deletions aem/ui.frontend/src/main/webpack/site/DialogHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,30 +99,9 @@ class DialogHistory {
}
}

/** Same as _.isEqual, but that's not available everywhere. */
/** More or less as _.isEqual, but that's not available everywhere. */
deepEquals(obj1, obj2) {
if (typeof obj1 !== typeof obj2) {
return false;
}

if (typeof obj1 !== 'object' || obj1 === null) {
return obj1 === obj2;
}

const keys1 = Object.keys(obj1);
const keys2 = Object.keys(obj2);

if (keys1.length !== keys2.length) {
return false;
}

for (const key of keys1) {
if (!this.deepEquals(obj1[key], obj2[key])) {
return false;
}
}

return true;
return JSON.stringify(obj1) === JSON.stringify(obj2);
}

}
Expand Down

0 comments on commit b1adf59

Please sign in to comment.