mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Chain listRef.current optionally
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
18587168dc
commit
57b211cea3
@ -75,7 +75,7 @@ export class VirtualList extends Component<Props, State> {
|
||||
const { items, rowHeights } = this.props;
|
||||
|
||||
if (prevProps.items.length !== items.length || !isEqual(prevProps.rowHeights, rowHeights)) {
|
||||
this.listRef.current.resetAfterIndex(0, false);
|
||||
this.listRef.current?.resetAfterIndex(0, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,11 +87,11 @@ export class VirtualList extends Component<Props, State> {
|
||||
const index = items.findIndex(item => item.getId() == selectedItemId);
|
||||
|
||||
if (index === -1) return;
|
||||
this.listRef.current.scrollToItem(index, "start");
|
||||
this.listRef.current?.scrollToItem(index, "start");
|
||||
});
|
||||
|
||||
scrollToItem = (index: number, align: Align) => {
|
||||
this.listRef.current.scrollToItem(index, align);
|
||||
this.listRef.current?.scrollToItem(index, align);
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user