Skip to content

Commit

Permalink
[IMP] web: drop event during click() dispatching if disabled
Browse files Browse the repository at this point in the history
Causes the failure of [0] on FF as it expects that clicking a disabled
button does nothing, which is what happens for Chrome, but the event
is dispatched for Firefox.

Asking the internet it looks like Firefox is in the right here:
click() ultimately calls dispatchEvent (directly), dispatchEvent
should go through even on disabled event. This was specifically fixed
in Firefox[1], and there is an issue opened against Chrome[2] (cf
also: spec discussion[3]).

There's an other issue which mentions inconsistencies between the
actual browser and WPT[4], but for us Chrome always 100% does the
"wrong" thing.

Anyway add a disabled flag in click, though I don't know that it's the
right fix, and it may need to be added to other events as well?

[0] https://github.com/odoo/odoo/blob/c89cdcf11c66e80c33cd77edceaee7eb59a704b3/addons/web/static/tests/fields/relational_fields/field_many2one_tests.js#L2044
[1] https://bugzilla.mozilla.org/show_bug.cgi?id=329509
[2] https://bugs.chromium.org/p/chromium/issues/detail?id=1115661
[3] whatwg/html#5805 (comment)
[4] https://bugs.chromium.org/p/chromium/issues/detail?id=1116161
  • Loading branch information
xmo-odoo authored and zel-odoo committed May 12, 2021
1 parent 61acc73 commit b244649
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addons/web/static/tests/helpers/test_utils_dom.js
Expand Up @@ -169,6 +169,9 @@ odoo.define('web.test_utils_dom', function (require) {
if (validMatches.length === 0 && matches.length > 0) {
throw new Error(`Element to click on is not visible ${selectorMsg}`);
}
if (target.disabled) {
return;
}

return triggerEvent(target, 'click');
}
Expand Down

0 comments on commit b244649

Please sign in to comment.