From c114614a28ad69afe8e698c2fcdaa8988fecb45a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Fri, 3 Dec 2021 14:32:52 +0000 Subject: [PATCH] [FIX] mail: properly render following canceled patching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, sometimes component do not properly render changes in the models. Although the modeling is correct, there is a problem in the component not re-rendering itself. The shouldUpdateBasedOnProps component hook did not consider update attempts that could be canceled. This commit adds this consideration, so that it ensures component is eventually rendered correctly Task-2410314 Task-2705078 closes odoo/odoo#80877 X-original-commit: 12c77f52c5a16c95e57de31587d67eda4d582bde Signed-off-by: Sébastien Theys (seb) Signed-off-by: Alexandre Kühn (aku) --- .../use_should_update_based_on_props.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/component_hooks/use_should_update_based_on_props/use_should_update_based_on_props.js b/addons/mail/static/src/component_hooks/use_should_update_based_on_props/use_should_update_based_on_props.js index b83d85d6c13..336278077bc 100644 --- a/addons/mail/static/src/component_hooks/use_should_update_based_on_props/use_should_update_based_on_props.js +++ b/addons/mail/static/src/component_hooks/use_should_update_based_on_props/use_should_update_based_on_props.js @@ -2,6 +2,7 @@ 'use strict'; const { Component } = owl; +const { onPatched } = owl.hooks; /** * Compares `a` and `b` up to the given `propsCompareDepth`. @@ -55,7 +56,11 @@ function isEqual(a, b, propsCompareDepth) { */ export function useShouldUpdateBasedOnProps({ propsCompareDepth = {} } = {}) { const component = Component.current; + let forceRender = false; component.shouldUpdate = nextProps => { + if (forceRender) { + return true; + } const allNewProps = Object.assign({}, nextProps); const defaultProps = component.constructor.defaultProps; for (const key in defaultProps) { @@ -63,6 +68,8 @@ export function useShouldUpdateBasedOnProps({ propsCompareDepth = {} } = {}) { allNewProps[key] = defaultProps[key]; } } - return !isEqual(component.props, allNewProps, propsCompareDepth); + forceRender = !isEqual(component.props, allNewProps, propsCompareDepth); + return forceRender; }; + onPatched(() => forceRender = false); }