Update npm non-major dependencies (#31662)
* Update npm non-major dependencies * Make types happier Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
co-authored by
renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Michael Telatynski
parent
7f057faaad
commit
4ee04d0661
@@ -76,6 +76,13 @@ export interface IListViewProps<Item, Context> extends Omit<
|
||||
onKeyDown?: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility type for the prop scrollIntoViewOnChange allowing it to be memoised by a caller without repeating types
|
||||
*/
|
||||
export type ScrollIntoViewOnChange<Item, Context = any> = NonNullable<
|
||||
VirtuosoProps<Item, ListContext<Context>>["scrollIntoViewOnChange"]
|
||||
>;
|
||||
|
||||
/**
|
||||
* A generic virtualized list component built on top of react-virtuoso.
|
||||
* Provides keyboard navigation and virtualized rendering for performance with large lists.
|
||||
|
||||
@@ -7,13 +7,12 @@
|
||||
|
||||
import React, { useCallback, useRef, type JSX } from "react";
|
||||
import { type Room } from "matrix-js-sdk/src/matrix";
|
||||
import { type ScrollIntoViewLocation } from "react-virtuoso";
|
||||
import { isEqual } from "lodash";
|
||||
|
||||
import { type RoomListViewState } from "../../../viewmodels/roomlist/RoomListViewModel";
|
||||
import { _t } from "../../../../languageHandler";
|
||||
import { RoomListItemView } from "./RoomListItemView";
|
||||
import { type ListContext, ListView } from "../../../utils/ListView";
|
||||
import { type ListContext, ListView, type ScrollIntoViewOnChange } from "../../../utils/ListView";
|
||||
import { type FilterKey } from "../../../../stores/room-list-v3/skip-list/filters";
|
||||
import { getKeyBindingsManager } from "../../../../KeyBindingsManager";
|
||||
import { KeyBindingAction } from "../../../../accessibility/KeyboardShortcuts";
|
||||
@@ -25,6 +24,12 @@ interface RoomListProps {
|
||||
*/
|
||||
vm: RoomListViewState;
|
||||
}
|
||||
|
||||
type Context = {
|
||||
spaceId: string;
|
||||
filterKeys: FilterKey[] | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Height of a single room list item
|
||||
*/
|
||||
@@ -48,10 +53,7 @@ export function RoomList({ vm: { roomsResult, activeIndex } }: RoomListProps): J
|
||||
(
|
||||
index: number,
|
||||
item: Room,
|
||||
context: ListContext<{
|
||||
spaceId: string;
|
||||
filterKeys: FilterKey[] | undefined;
|
||||
}>,
|
||||
context: ListContext<Context>,
|
||||
onFocus: (item: Room, e: React.FocusEvent) => void,
|
||||
): JSX.Element => {
|
||||
const itemKey = item.roomId;
|
||||
@@ -78,10 +80,8 @@ export function RoomList({ vm: { roomsResult, activeIndex } }: RoomListProps): J
|
||||
return item.roomId;
|
||||
}, []);
|
||||
|
||||
const scrollIntoViewOnChange = useCallback(
|
||||
(params: {
|
||||
context: ListContext<{ spaceId: string; filterKeys: FilterKey[] | undefined }>;
|
||||
}): ScrollIntoViewLocation | null | undefined | false | void => {
|
||||
const scrollIntoViewOnChange = useCallback<ScrollIntoViewOnChange<Room, Context>>(
|
||||
(params) => {
|
||||
const { spaceId, filterKeys } = params.context.context;
|
||||
const shouldScrollIndexIntoView =
|
||||
lastSpaceId.current !== spaceId || !isEqual(lastFilterKeys.current, filterKeys);
|
||||
|
||||
Reference in New Issue
Block a user