Skip to content

Commit

Permalink
MDL-43334 backup: Fix cancel JS
Browse files Browse the repository at this point in the history
The cancel button is a form element within a div that has the confirmcancel class. When we
accept a cancel modal, we should attempt to click the most specific form element of the
div, not the entire div.
  • Loading branch information
Damyon Wiese committed Jul 9, 2018
1 parent ddd7ff1 commit 6fea9dc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
Expand Up @@ -68,8 +68,17 @@ M.core_backup.confirmcancel = {
// Detach the listeners for the confirm box so they don't fire again.
new Y.EventHandle(M.core_backup.confirmcancel.listeners).detach();

// The currentTarget is a div surrounding the form elements. Simulating a click on the div is
// not going to submit a form so we need to find the form element to click.
var element = e.currentTarget.one('input, select, button');

// Simulate the original cancel button click.
e.currentTarget.simulate('click');
if (element) {
element.simulate('click');
} else {
// Backwards compatibility only.
e.currentTarget.simulate('click');
}
}, this);


Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -68,8 +68,17 @@ M.core_backup.confirmcancel = {
// Detach the listeners for the confirm box so they don't fire again.
new Y.EventHandle(M.core_backup.confirmcancel.listeners).detach();

// The currentTarget is a div surrounding the form elements. Simulating a click on the div is
// not going to submit a form so we need to find the form element to click.
var element = e.currentTarget.one('input, select, button');

// Simulate the original cancel button click.
e.currentTarget.simulate('click');
if (element) {
element.simulate('click');
} else {
// Backwards compatibility only.
e.currentTarget.simulate('click');
}
}, this);


Expand Down
11 changes: 10 additions & 1 deletion backup/util/ui/yui/src/confirmcancel/js/confirmcancel.js
Expand Up @@ -66,8 +66,17 @@ M.core_backup.confirmcancel = {
// Detach the listeners for the confirm box so they don't fire again.
new Y.EventHandle(M.core_backup.confirmcancel.listeners).detach();

// The currentTarget is a div surrounding the form elements. Simulating a click on the div is
// not going to submit a form so we need to find the form element to click.
var element = e.currentTarget.one('input, select, button');

// Simulate the original cancel button click.
e.currentTarget.simulate('click');
if (element) {
element.simulate('click');
} else {
// Backwards compatibility only.
e.currentTarget.simulate('click');
}
}, this);


Expand Down

0 comments on commit 6fea9dc

Please sign in to comment.