Skip to content

Commit

Permalink
fix: disables the submit button on click of reset button
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
imasdekar committed Jul 10, 2024
1 parent aa70fea commit 005be1b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions xmodule/js/src/capa/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
};
Expand Down

0 comments on commit 005be1b

Please sign in to comment.