From 3ce4e7f9aa9e3697b6b4363df68d3f7733d42bc3 Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Thu, 15 Dec 2022 15:17:12 +0000 Subject: [PATCH] [FIX] website: convert bootstrap modal option Before this commit, the popup snippets were configuring the modal option for bootstrap 4 rather than 5. The `data-focus` in bootstrap 4 becomes `data-bs-focus` in bootstap 5. Without `data-bs-focus` option, the Newsletter popup snippet became uneditable because any click inside popup changed the selection to be inside the first focusable element within the modal. The reason of the input being focused is: upon click inside the modal, the target of the focusin event is the parent of the modal because that parent is contenteditable="true". Because that target is outside the modal, `_handleFocusin` correct the selection by focusing the text input. task-3102155 closes odoo/odoo#109148 X-original-commit: bc99f3cdb5c2fca59a24dc4970c9ca6e69721838 Signed-off-by: David Monjoie (dmo) --- addons/website/static/src/snippets/s_popup/options.js | 7 +++++++ addons/website/views/snippets/s_popup.xml | 2 +- addons/website_mass_mailing/views/snippets_templates.xml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/snippets/s_popup/options.js b/addons/website/static/src/snippets/s_popup/options.js index eff496375b8..e73ab7d3e82 100644 --- a/addons/website/static/src/snippets/s_popup/options.js +++ b/addons/website/static/src/snippets/s_popup/options.js @@ -49,6 +49,13 @@ options.registry.SnippetPopup = options.Class.extend({ */ onBuilt: function () { this._assignUniqueID(); + // Fix in stable to convert the data-focus bootstrap option from version 4.0 to + // 5.1 (renamed to data-bs-focus). + const popup = this.$target.closest('.s_popup_middle'); + if (popup && popup.attr('data-focus')) { + popup.attr('data-bs-focus', popup.attr('data-focus')); + popup[0].removeAttribute('data-focus'); + } }, /** * @override diff --git a/addons/website/views/snippets/s_popup.xml b/addons/website/views/snippets/s_popup.xml index 61493434643..56d428b66cb 100644 --- a/addons/website/views/snippets/s_popup.xml +++ b/addons/website/views/snippets/s_popup.xml @@ -7,7 +7,7 @@ their XML definition here as that would hurt the drag and drop feature. -->
-