summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components/composer/composer.js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-11-16 12:36:47 +0000
committerSébastien Theys <seb@odoo.com>2020-11-16 12:36:47 +0000
commit2002c6a599a685f4a18fc670a9f7992c8d595c0f (patch)
treee4d273d6cd86496d68e9ebd02c3849d9f52d95d1 /addons/mail/static/src/components/composer/composer.js
parent8b32e558fde3cb3aaa1deb40acb07488d04d343e (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/composer/composer.js')
-rw-r--r--addons/mail/static/src/components/composer/composer.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/addons/mail/static/src/components/composer/composer.js b/addons/mail/static/src/components/composer/composer.js
index 6c9965a57d1..4434697f8fb 100644
--- a/addons/mail/static/src/components/composer/composer.js
+++ b/addons/mail/static/src/components/composer/composer.js
@@ -11,6 +11,7 @@ const components = {
ThreadTextualTypingStatus: require('mail/static/src/components/thread_textual_typing_status/thread_textual_typing_status.js'),
};
const useDragVisibleDropZone = require('mail/static/src/component_hooks/use_drag_visible_dropzone/use_drag_visible_dropzone.js');
+const useUpdate = require('mail/static/src/component_hooks/use_update/use_update.js');
const useStore = require('mail/static/src/component_hooks/use_store/use_store.js');
const {
isEventHandled,
@@ -38,6 +39,7 @@ class Composer extends Component {
: undefined,
};
});
+ useUpdate({ func: () => this._update() });
/**
* Reference of the emoji popover. Useful to include emoji popover as
* contained "inside" the composer.
@@ -61,11 +63,6 @@ class Composer extends Component {
mounted() {
document.addEventListener('click', this._onClickCaptureGlobal, true);
- this._update();
- }
-
- patched() {
- this._update();
}
willUnmount() {
@@ -201,6 +198,9 @@ class Composer extends Component {
* @private
*/
_update() {
+ if (!this.composer) {
+ return;
+ }
if (this._subjectRef.el) {
this._subjectRef.el.value = this.composer.subjectContent;
}