From 55c802de4485dfe14996bea18b21206c682b410a Mon Sep 17 00:00:00 2001 From: Alexey Morozov Date: Fri, 10 Jul 2026 23:06:29 +0300 Subject: [PATCH] Restore scroll position in `ConnectionsMenu` when going back to relation types from instances list --- CHANGELOG.md | 1 + src/widgets/connectionsMenu/connectionList.tsx | 8 ++++++-- src/widgets/connectionsMenu/connectionsMenu.tsx | 6 +++--- ...{connectionsList.test.tsx => connectionsMenu.test.tsx} | 6 +++--- 4 files changed, 13 insertions(+), 8 deletions(-) rename test/widgets/{connectionsList.test.tsx => connectionsMenu.test.tsx} (89%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39aca1a4..f95ea3d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Fix relation having changed `data` but missing from `AuthoringState` when the source or target entity becomes deleted then restored back. - Fix grouped relation (`RelationGroup` item) does not updating its `data` when changed by `EditorController`. - Fix `ConnectionsMenu` displaying no links when there is only a single incoming/outgoing relation type. (by @cristianvasquez) +- Restore scroll position in `ConnectionsMenu` when going back to relation types from instances list. - Exclude collapsed `DropdownMenu` and `UnifiedSearch` content from Tab-navigation. - Exclude canvas elements from Tab-navigation unless the element is only one selected. - Block canvas interacton (including Tab-navigation) when displaying a blocking modal overlay i.e. an overlay task or viewport-centered dialog. diff --git a/src/widgets/connectionsMenu/connectionList.tsx b/src/widgets/connectionsMenu/connectionList.tsx index df0f4080..e58ec7b2 100644 --- a/src/widgets/connectionsMenu/connectionList.tsx +++ b/src/widgets/connectionsMenu/connectionList.tsx @@ -17,7 +17,7 @@ import { CLASS_NAME, LINK_COUNT_PER_PAGE, } from './menuCommon'; -export function ConnectionsList(props: { +export function ConnectionList(props: { data: ConnectionsData; filterKey: string; sortMode: SortMode; @@ -27,7 +27,7 @@ export function ConnectionsList(props: { onExpandLink: (chunk: LinkDataChunk) => void; onMoveToFilter?: (chunk: LinkDataChunk) => void; - scrolledListRef?: React.RefObject; + scrolledListRef?: React.RefObject; }) { const { data, filterKey, sortMode, suggestions, @@ -99,6 +99,10 @@ export function ConnectionsList(props: { 'reactodia-scrollable', entries.length === 0 ? `${CLASS_NAME}__links-list-empty` : undefined )} + ref={ + /* For compatibility with React 19 typings */ + scrolledListRef as React.RefObject + } tabIndex={-1} > diff --git a/src/widgets/connectionsMenu/connectionsMenu.tsx b/src/widgets/connectionsMenu/connectionsMenu.tsx index ada5a2a1..0414707d 100644 --- a/src/widgets/connectionsMenu/connectionsMenu.tsx +++ b/src/widgets/connectionsMenu/connectionsMenu.tsx @@ -31,7 +31,7 @@ import { ConnectionCount, ObjectsData, LinkDataChunk, ObjectPlacingMode, CLASS_NAME, LINK_COUNT_PER_PAGE, LoadingSpinner, } from './menuCommon'; -import { ConnectionsList } from './connectionList'; +import { ConnectionList } from './connectionList'; import { EntityList } from './entityList'; /** @@ -258,7 +258,7 @@ class ConnectionsMenuInner extends React.Component(); + private linksScrolledListRef = React.createRef(); private linksScrollPosition: number | undefined; constructor(props: ConnectionsMenuInnerProps) { @@ -598,7 +598,7 @@ class ConnectionsMenuInner extends React.Component { +describe('ConnectionList', () => { it('renders the only connection link', async () => { const link: LinkTypeModel = {id: 'urn:test:single-link', label: []}; const workspace = createWorkspace({ @@ -16,7 +16,7 @@ describe('ConnectionsList', () => { await render( -