diff --git a/src/components/utils/ListView.tsx b/src/components/utils/ListView.tsx index 9df5b67e69..36b33186c9 100644 --- a/src/components/utils/ListView.tsx +++ b/src/components/utils/ListView.tsx @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import React, { useRef, type JSX, useCallback, useEffect, useState } from "react"; +import React, { useRef, type JSX, useCallback, useEffect, useState, useMemo } from "react"; import { type VirtuosoHandle, type ListRange, Virtuoso, type VirtuosoProps } from "react-virtuoso"; import { isModifiedKeyEvent, Key } from "../../Keyboard"; @@ -293,11 +293,14 @@ export function ListView(props: IListViewProps = { - tabIndexKey: tabIndexKey, - focused: isFocused, - context: props.context || ({} as Context), - }; + const listContext: ListContext = useMemo( + () => ({ + tabIndexKey: tabIndexKey, + focused: isFocused, + context: props.context || ({} as Context), + }), + [tabIndexKey, isFocused, props.context], + ); return ( ( + () => ({ spaceId: roomsResult.spaceId, filterKeys: roomsResult.filterKeys }), + [roomsResult.spaceId, roomsResult.filterKeys], + ); return (