diff --git a/change/@fluentui-react-tree-e91902ae-b031-47c0-99be-2f7450c3f3f7.json b/change/@fluentui-react-tree-e91902ae-b031-47c0-99be-2f7450c3f3f7.json new file mode 100644 index 0000000000000..fe7fa3fe12076 --- /dev/null +++ b/change/@fluentui-react-tree-e91902ae-b031-47c0-99be-2f7450c3f3f7.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "bugfix: fix VisibleFlatTreeItemGenerator omitting visible items", + "packageName": "@fluentui/react-tree", + "email": "bernardo.sunderhus@gmail.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-components/react-tree/src/utils/createFlatTreeItems.ts b/packages/react-components/react-tree/src/utils/createFlatTreeItems.ts index 6643c14990f5e..7c564d93e3fa8 100644 --- a/packages/react-components/react-tree/src/utils/createFlatTreeItems.ts +++ b/packages/react-components/react-tree/src/utils/createFlatTreeItems.ts @@ -109,12 +109,12 @@ export function* VisibleFlatTreeItemGenerator; - const parent = item.parentValue ? flatTreeItems.get(item.parentValue) ?? flatTreeItems.root : flatTreeItems.root; if (isItemVisible(item, openItems, flatTreeItems)) { item.index = visibleIndex++; yield item; } else { - index += parent.childrenSize - 1 + item.childrenSize; + // Jump the amount of children the current item has, since those items will also be hidden + index += item.childrenSize; } } }