diff options
| author | Sébastien Theys <seb@odoo.com> | 2020-11-16 12:36:47 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-11-16 12:36:47 +0000 |
| commit | 2002c6a599a685f4a18fc670a9f7992c8d595c0f (patch) | |
| tree | e4d273d6cd86496d68e9ebd02c3849d9f52d95d1 /addons/mail/static/src/components/chat_window | |
| parent | 8b32e558fde3cb3aaa1deb40acb07488d04d343e (diff) | |
[FIX] mail: fix race conditions, especially with scroll
The `_update` of some components must take place before the `_update`
of other (usually sibling) components that might directly influence their
layout. This is in particular the case for `_update` that are relying on height.
Prevent force save of scroll position if there are pending hints to adjust it,
and prevent pending hints from overriding new scroll value.
Prevent flicker with message date.
This should fix all known issues related to incorrectly saving or restoring
scroll position.
task-2344226
task-2358066
task-2369332
task-2372339
task-2373741
closes odoo/odoo#61054
Related: odoo/enterprise#14736
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/chat_window')
| -rw-r--r-- | addons/mail/static/src/components/chat_window/chat_window.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/addons/mail/static/src/components/chat_window/chat_window.js b/addons/mail/static/src/components/chat_window/chat_window.js index 28e7f08a1fb..27d6bb68b68 100644 --- a/addons/mail/static/src/components/chat_window/chat_window.js +++ b/addons/mail/static/src/components/chat_window/chat_window.js @@ -7,6 +7,7 @@ const components = { ThreadView: require('mail/static/src/components/thread_view/thread_view.js'), }; const useStore = require('mail/static/src/component_hooks/use_store/use_store.js'); +const useUpdate = require('mail/static/src/component_hooks/use_update/use_update.js'); const { isEventHandled } = require('mail/static/src/utils/utils.js'); const { Component } = owl; @@ -29,6 +30,7 @@ class ChatWindow extends Component { thread: thread ? thread.__state : undefined, }; }); + useUpdate({ func: () => this._update() }); /** * Reference of the header of the chat window. * Useful to prevent click on header from wrongly focusing the window. @@ -55,11 +57,6 @@ class ChatWindow extends Component { mounted() { this.env.messagingBus.on('will_hide_home_menu', this, this._onWillHideHomeMenu.bind(this)); this.env.messagingBus.on('will_show_home_menu', this, this._onWillShowHomeMenu.bind(this)); - this._update(); - } - - patched() { - this._update(); } willUnmount() { @@ -132,7 +129,16 @@ class ChatWindow extends Component { * @private */ _saveThreadScrollTop() { - if (!this._threadRef.comp || !this.chatWindow.threadViewer) { + if ( + !this._threadRef.comp || + !this.chatWindow.threadViewer || + !this.chatWindow.threadViewer.threadView + ) { + return; + } + if (this.chatWindow.threadViewer.threadView.componentHintList.length > 0) { + // the current scroll position is likely incorrect due to the + // presence of hints to adjust it return; } this.chatWindow.threadViewer.saveThreadCacheScrollHeightAsInitial( |
