From f186f8d05aa5f3a3528918621963a2fde4c593b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Todorovich?= Date: Tue, 11 Feb 2025 10:56:18 -0300 Subject: [PATCH] [FIX] web: properly handle form state with nested notebooks Steps to reproduce: 1. Create a form with a notebook, with pages "A", "B", and "C" 2. In page "B", create another notebook with a name="notebook_B", and pages "1", "2", and "3". 3. Create a record on this form, and focus on page "B" and then page "3". 4. Click on the "Edit" button Result: - The page "C" is focused Expected: - Focus shouldn't change Explanation: The focused page is handled by the `getLocalState` and `setLocalState` methods, which are used to store the focused page index for each notebook on the form. However, the code doesn't handle properly the case of nested forms: when trying to identify the focused page index, it's looping through all the nested pages. This commit modifies the selector used to only look for the direct page elements. --- addons/web/static/src/js/views/form/form_renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index 0ee663f762315e..c422d5f4cd59d7 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -198,7 +198,7 @@ var FormRenderer = BasicRenderer.extend({ var $notebook = $(this); var name = $notebook.data('name'); var index = -1; - $notebook.find('.nav-link').each(function (i) { + $notebook.find('> ul > li > a.nav-link').each(function (i) { if ($(this).hasClass('active')) { index = i; }