Bug 1930589 - Fix scrolling for tree listbox items that have no children. r=tobyp

Differential Revision: https://phabricator.services.mozilla.com/D228628

--HG--
extra : amend_source : f29e6273daf1365ae524d2533488b0f06551d788
This commit is contained in:
Geoff Lankow 2024-11-13 11:24:30 +01:00
Родитель 284c645a4c
Коммит 0ccfff11c9
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -710,7 +710,16 @@ export const TreeListboxMixin = Base =>
if (this.selectedIndex == index) {
row.classList.add("current");
this.setAttribute("aria-activedescendant", row.id);
row.firstElementChild.scrollIntoView({ block: "nearest" });
if (this.isTree) {
// We don't want to scroll to the item and its entire subtree, so
// scroll only to the first child. Typically items in a tree have
// a block containing the item icon, name, etc. followed by a list
// containing the child items, so this works.
row.firstElementChild.scrollIntoView({ block: "nearest" });
} else {
// Not a tree item, scroll the whole item into view.
row.scrollIntoView({ block: "nearest" });
}
}
});