Friday, March 6, 2026
1 change · 19.0
Resolved issues and error corrections
This fix protects marketing email edits from being lost when users switch tabs or navigate away while the editor is still processing changes. It also reduces visual flicker during email conversion and makes save behavior more reliable in the mailing editor.
Original PR description
Main issue: Prior to this commit, updateValue would guarantee that `body_arch` and `body_html` were always updated in sync (to avoid an inconsistent state where the user thinks they updated the…
Main issue: Prior to this commit, updateValue would guarantee that `body_arch` and `body_html` were always updated in sync (to avoid an inconsistent state where the user thinks they updated the mailing, and they see the new html in the editor, but the email html is obsolete and would be sent as is). However this caused another issue, that the user would lose their work when switching tab in the Notebook, because computing the `body_html` may be slower than the view patch to switch tab (`updateValue` is interrupted). In such a case, neither `body_arch` nor `body_html` was updated on the record, and when the user comes back to edit them, they see that all changes were lost. To prevent this, a new strategy is adopted: - `body_arch` is now updated as soon as possible to save the latest user changes - `body_html` is set to an empty string to avoid inconsistencies, and in order to trigger `convert_inline` automatically the next time the `mass_mailing_html_field` is instanced without any user action. - after `convert_inline`, if `updateValue` was not aborted, the record is updated again with the new value for `body_html` Minor issues: 1) Prior to this commit, the iframe would flicker during `convert_inline` because it was done inside that very iframe, and the `convert_inline` needs a specific width (1320px) for it to work properly, meaning that if the iframe was not at that specific dimension, it was resized temporarily for that process. This commit introduces hooks to execute the `convert_inline` process in a separate iframe, outside of the user view, which removes this flickering. 2) Prior to this commit, assets for readonly/basic editor/builder were all loaded inside the iframe, and then toggled on/off depending on which were needed. Since the `convert_inline` process is moved in another iframe, it's as good time as any to deprecate this toggling (as it could be a bit unreliable and could cause some flickering when unloading/reloading the style). There is now a separate asset bundle for the 3 use case, and only one of them is loaded per iframe depending on the needs. 3) Prior to this commit, `body_html` was hard-coded as a dependency of the `mass_mailing_html_field`, and that dependency lacked the `required` attribute, which should depend on the value of `body_arch`. The dependency is now added in the related views, and the field is now generic. This also prevents the user from leaving the view if `convert_inline` could not be completed successfully. 4) Prior to this commit, switching to another view through `doAction` could throw an error if the field was dirty, as the `form view` would be destroyed before `commitChanges` had the time to be completed. Now, `commitChanges` promise is properly awaited by the `action_service` if the field is dirty before `doAction` (unless `forceLeave` is true). 5) Prior to this commit, the record was updated through a `blur` event on the iframe window. However, it means that every time the iframe looses focus when the users interacts with the builder, a popover or the form status indicator, that blur event would fire, triggering the `convert_inline` process. This commit reduces the amount of such updates by only triggering the update outside of these elements, as we don't need to update the record value while the user is still actively editing the mailing. Blur handlers/props are deprecated with this commit and will be removed further down the line. 6) Ensure that in the rare case where a `html_field` value is exactly the same on different records, the `html_field` state key is updated (triggers a wysiwyg/mass_mailing_iframe reset). 7) Remove an erroneous part in `onWillUpdateProps` of `mass_mailing_html_field` which could display the theme selector again on the same record just after selecting a theme if props were updated. 8) Ensure `withBuilder` getter of `mass_mailing_html_field` properly reads the state activeTheme every time it is used (if it does not, it could cause issues with the reactivity, since reading on the state is required for a property subscription). 9) Remove a useless `onWillUpdateProps` of `mass_mailing_iframe` which was never used because when `props.showCodeView` changes, the iframe is always destroyed, so there is no need to update its state. 10) Deprecate usage of `<meta http-equiv="X-UA-Compatible" content="IE=edge"/>`, to be removed further down the line, as it is useless in the modern web. 11) Ignore errors during a builder "Operation" that was not finished before the editor was destroyed. In `mass_mailing`, the editor is expected to be destroyable synchronously to work inside an Odoo view, unlike in `website`. What's already in the DOM just before destruction will be updated on the `record`, and the rest of the operation will be lost. However, an attempt is made to wait for ongoing operations at the start of the `HtmlField.commitChanges`. task-5976348