DetailList scrollToIndex( ) or focusIndex( ) doesn't work #25177
-
I am trying to scroll to the specified index of the list when the component is rendered using focusIndex( ) and scrollToIndex( ) but neither seems to be working. Here's my codepen: Would like to know if I'm missing anything or why it's not working |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@iron-man14 I've looked into this a bit and there are two issues at work. One is a bug in The bug in To address the bug in import { GroupedListV2_unstable as GroupedListV2 } from '@fluentui/react';
<DetailsList
{...allOtherProps}
groupProps={{
groupedListAs: GroupedListV2
}}
/> While this will allow componentDidMount() {
requestAnimationFrame(() => {
this.ref.current.focusIndex(450);
});
} Note that you do not need to call I've forked and updated your example here: https://codepen.io/seanms/pen/mdLZPmo NOTE: To get an idea of the missing features and work-to-be-done in |
Beta Was this translation helpful? Give feedback.
@iron-man14 I've looked into this a bit and there are two issues at work. One is a bug in
scrollToIndex()
when used with groupedDetailsList
(orGroupedList
). The other relates toList
's rendering behavior (List
being the control thatDetailsList
andGroupedList
use under the hood to render lists).The bug in
scrollToIndex()
is that, with grouped lists, each group is actually aList
with its own indexes butList.scrollToIndex()
only has a concept of a flat list so it does not know to look into sub-List
s. In your example the root list has 10 groups which means the list has 10 indexes so it cannot find index 450.To address the bug in
scrollToIndex()
you can use the (in preview, not ready f…