diff options
| author | Didier (did) <did@odoo.com> | 2020-11-05 12:37:15 +0000 |
|---|---|---|
| committer | Didier (did) <did@odoo.com> | 2020-11-17 08:11:20 +0000 |
| commit | 69432fbe47f8cf6ca89f018e38961fdeba8b0fc7 (patch) | |
| tree | ea58dcbca5e2f80013b4ce65493ae1dfb5fa54f6 /addons/mail/static/src/components/message | |
| parent | 2abc90263fead40223a98f0d2e20b9cd80bd9572 (diff) | |
[FIX] mail,sms: avoid event propagation on avatar click in message list
Before this commit, when a user click on the author avatar inside the message
list, it trigger the o-clicked for the message.
task-2341603
closes odoo/odoo#61400
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Co-authored-by: Sébastien Theys <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/message')
| -rw-r--r-- | addons/mail/static/src/components/message/message.js | 12 | ||||
| -rw-r--r-- | addons/mail/static/src/components/message/message_tests.js | 9 |
2 files changed, 16 insertions, 5 deletions
diff --git a/addons/mail/static/src/components/message/message.js b/addons/mail/static/src/components/message/message.js index 4a89514b39a..2498953e6e3 100644 --- a/addons/mail/static/src/components/message/message.js +++ b/addons/mail/static/src/components/message/message.js @@ -21,6 +21,7 @@ const { useRef } = owl.hooks; const READ_MORE = _lt("read more"); const READ_LESS = _lt("read less"); +const { isEventHandled, markEventHandled } = require('mail/static/src/utils/utils.js'); class Message extends Component { @@ -441,7 +442,13 @@ class Message extends Component { } return; } - this.state.isClicked = !this.state.isClicked; + if ( + !isEventHandled(ev, 'Message.ClickAuthorAvatar') && + !isEventHandled(ev, 'Message.ClickAuthorName') && + !isEventHandled(ev, 'Message.ClickFailure') + ) { + this.state.isClicked = !this.state.isClicked; + } } /** @@ -449,6 +456,7 @@ class Message extends Component { * @param {MouseEvent} ev */ _onClickAuthorAvatar(ev) { + markEventHandled(ev, 'Message.ClickAuthorAvatar'); if (!this.hasAuthorOpenChat) { return; } @@ -460,6 +468,7 @@ class Message extends Component { * @param {MouseEvent} ev */ _onClickAuthorName(ev) { + markEventHandled(ev, 'Message.ClickAuthorName'); if (!this.message.author) { return; } @@ -471,6 +480,7 @@ class Message extends Component { * @param {MouseEvent} ev */ _onClickFailure(ev) { + markEventHandled(ev, 'Message.ClickFailure'); this.message.openResendAction(); } diff --git a/addons/mail/static/src/components/message/message_tests.js b/addons/mail/static/src/components/message/message_tests.js index a880169967b..168faa342e7 100644 --- a/addons/mail/static/src/components/message/message_tests.js +++ b/addons/mail/static/src/components/message/message_tests.js @@ -4,6 +4,7 @@ odoo.define('mail/static/src/components/message/message_tests.js', function (req const components = { Message: require('mail/static/src/components/message/message.js'), }; +const { makeDeferred } = require('mail/static/src/utils/deferred/deferred.js'); const { afterEach, afterNextRender, @@ -266,6 +267,7 @@ QUnit.test('Notification Sent', async function (assert) { QUnit.test('Notification Error', async function (assert) { assert.expect(8); + const openResendActionDef = makeDeferred(); const bus = new Bus(); bus.on('do-action', null, payload => { assert.step('do_action'); @@ -279,6 +281,7 @@ QUnit.test('Notification Error', async function (assert) { 10, "action should have correct message id" ); + openResendActionDef.resolve(); }); await this.start({ env: { bus } }); @@ -323,10 +326,8 @@ QUnit.test('Notification Error', async function (assert) { 'fa-envelope', "icon should represent email error" ); - - await afterNextRender(() => { - document.querySelector('.o_Message_notificationIconClickable').click(); - }); + document.querySelector('.o_Message_notificationIconClickable').click(); + await openResendActionDef; assert.verifySteps( ['do_action'], "should do an action to display the resend email dialog" |
