Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] website, test_website: fix cache for navbar active element
Since [this other commit], the style indicating the active nav item stopped working if the user added record pages to the navbar. This was due to the cache system not being invalidated when switching from one record page to another. This commit fixes the issue by disabling the cache for the navbar if there is a record page in the menu. Other potential solutions were considered but ultimately rejected: 1. Using the record as a t-cache key. However, this would mean that if you have 60,000 visible forum posts, you would end up with 60,000 different caches. 2. Activate the correct element using JavaScript. This would lead to a duplicate logic in the JavaScript and the Python code, and it would introduces a slight lag to add the active class on the correct nav item (due to the time it takes to load and execute the JavaScript). The chosen solution is the best compromise, as it maintains the cache for most cases (website menu without records page links in it), nothing change with this commit. For problematic cases (record pages in the website menu), this commit disables the cache, which is a reasonable trade-off. Steps to reproduce the bug fixed by this commit: - Edit a website's menu - Add a link to a product page (e.g., customizable-desk) - Add a link to another product (e.g., chair-floor-protection) - Save the menu - Click on the menu link to go to customizable-desk => At this point, the active menu element is correct - Click on the menu link to go to chair-floor-protection => The active menu element does not update This commit fixes the issue (a update of the website module is needed) and adds a test to prevent regressions. Notes: - To see the issue locally, remove the --dev xml or --dev all arguments. - The same issue was occurring with other record pages (blog posts, ..). - We will introduce back the groups on menu and benefit from this new method to also disable the menu cache if one of the menu is linked to a group. See task-3800830 [this other commit]: b0a2a41 opw-3694651 opw-3750925 opw-3781668 closes #159191 X-original-commit: 9c8c860 Related: odoo/enterprise#59399 Signed-off-by: Romain Derie (rde) <rde@odoo.com> Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
- Loading branch information