custom_emojis: Fix unresponsiveness after submitting without a name.

While adding custom emojis, when a user clicks on the submit
button without providing a name to the emoji, the submit button
becomes unresponsive. This commit fixes that.

Fixes #16921
This commit is contained in:
ganpa 2020-12-29 14:27:34 +05:30 committed by Tim Abbott
parent 1498b2ef69
commit b1f4c98730
1 changed files with 10 additions and 1 deletions

View File

@ -175,7 +175,6 @@ exports.set_up = function () {
e.preventDefault();
e.stopPropagation();
const emoji_status = $("#admin-emoji-status");
$("#admin_emoji_submit").prop("disabled", true);
const emoji = {};
const formData = new FormData();
@ -183,6 +182,16 @@ exports.set_up = function () {
emoji[obj.name] = obj.value;
}
if (emoji.name.trim() === "") {
ui_report.message(
i18n.t("Failed: Emoji name is required."),
emoji_status,
"alert-error",
);
return;
}
$("#admin_emoji_submit").prop("disabled", true);
for (const [i, file] of Array.prototype.entries.call($("#emoji_file_input")[0].files)) {
formData.append("file-" + i, file);
}