[FIX] odoo_theme: update the aria attributes when scrolling the page TOC

The 'aria-expanded' attribute was not correctly updated on the `i` tag
when the user scrolled through the page TOC. This caused a minor issue
where an arrow (`i`) that was collapsed manually with a click would no
longer automatically expand afterward.

task-3106339

closes odoo/documentation#3239

X-original-commit: f068065d39
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
Antoine Vandevenne (anv) 2022-12-21 14:42:06 +00:00
parent 520cd5fb9e
commit 03573426e1

View File

@ -16,8 +16,7 @@
// Allow to automatically collapse and expand TOC entries
_prepareAccordion(pageToc);
// Allow to respectively highlight and expand the TOC entries and their related TOC
// entry list whose section is focused.
// Highlight TOC entries whose section is focused and expand their TOC entry list.
_flagActiveTocEntriesAndLists(pageToc, headingRefs);
// Allow to hide the TOC entry referring the title (<h1> heading)
@ -98,6 +97,12 @@
// Highlight all <li> in the active hierarchy
tocEntry.classList.add('o_active_toc_entry');
// Update the attributes on the <i>.
const tocEntryWrapper = tocEntry.querySelector('.o_toc_entry_wrapper');
if (tocEntryWrapper) {
tocEntryWrapper.querySelector('i').setAttribute('aria-expanded', true);
}
// Expand all related <ul>
const relatedTocEntryList = tocEntry.querySelector('ul');
if (relatedTocEntryList) {