From 005be1b7fb4b2ac204d1fb67a765b9955371e571 Mon Sep 17 00:00:00 2001 From: Ishan Masdekar Date: Wed, 10 Jul 2024 23:39:47 +0530 Subject: [PATCH] fix: disables the submit button on click of reset button - whenever the reset button is clicked the submit button is disabled except for cases when there is a gentle alert notification closes openedx/frontend-app-learning#1406 Signed-off by: Ishan Masdekar --- xmodule/js/src/capa/display.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xmodule/js/src/capa/display.js b/xmodule/js/src/capa/display.js index f4254b43f8ff..e549bcf694c2 100644 --- a/xmodule/js/src/capa/display.js +++ b/xmodule/js/src/capa/display.js @@ -1224,11 +1224,21 @@ Problem.prototype.disableAllButtonsWhileRunning = function(operationCallback, isFromCheckOperation) { var that = this; var allButtons = [this.resetButton, this.saveButton, this.showButton, this.hintButton, this.submitButton]; + // require this array to enable all except submit buttom + var buttonsExceptSubmit = [this.resetButton, this.saveButton, this.showButton, this.hintButton]; var initiallyEnabledButtons = allButtons.filter(function(button) { return !button.attr('disabled'); }); this.enableButtons(initiallyEnabledButtons, false, isFromCheckOperation); return operationCallback().always(function() { + if (!(isFromCheckOperation)){ + // submit button is enabled conditionally during a reset operation + if (that.el.find(".notification-gentle-alert .notification-message:visible").length === 0){ + that.enableButtons([that.submitButton], false, isFromCheckOperation); + return that.enableButtons(buttonsExceptSubmit, true, isFromCheckOperation); + + } + } return that.enableButtons(initiallyEnabledButtons, true, isFromCheckOperation); }); };