diff options
| -rw-r--r-- | gui/src/renderer/components/select-location/RelayListContext.tsx | 4 | ||||
| -rw-r--r-- | gui/src/renderer/components/select-location/ScrollPositionContext.tsx | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/gui/src/renderer/components/select-location/RelayListContext.tsx b/gui/src/renderer/components/select-location/RelayListContext.tsx index b37cced8b5..0c99125605 100644 --- a/gui/src/renderer/components/select-location/RelayListContext.tsx +++ b/gui/src/renderer/components/select-location/RelayListContext.tsx @@ -179,7 +179,7 @@ function useRelayList( // Return all RelayLocations that should be expanded function useExpandedLocations(filteredLocations: Array<IRelayLocationRedux>) { const { locationType, searchTerm } = useSelectLocationContext(); - const { spacePreAllocationViewRef, scrollViewRef } = useScrollPositionContext(); + const { spacePreAllocationViewRef, scrollIntoView } = useScrollPositionContext(); const relaySettings = useNormalRelaySettings(); const bridgeSettings = useNormalBridgeSettings(); @@ -217,7 +217,7 @@ function useExpandedLocations(filteredLocations: Array<IRelayLocationRedux>) { if (invokedByUser) { locationRect.height += expandedContentHeight; spacePreAllocationViewRef.current?.allocate(expandedContentHeight); - scrollViewRef.current?.scrollIntoView(locationRect); + scrollIntoView(locationRect); } }, [], diff --git a/gui/src/renderer/components/select-location/ScrollPositionContext.tsx b/gui/src/renderer/components/select-location/ScrollPositionContext.tsx index cdb7aba044..b020e76227 100644 --- a/gui/src/renderer/components/select-location/ScrollPositionContext.tsx +++ b/gui/src/renderer/components/select-location/ScrollPositionContext.tsx @@ -17,6 +17,7 @@ interface ScrollPositionContext { spacePreAllocationViewRef: React.RefObject<SpacePreAllocationView>; saveScrollPosition: () => void; resetScrollPositions: () => void; + scrollIntoView: (rect: DOMRect) => void; } type ScrollPosition = [number, number]; @@ -58,6 +59,10 @@ export function ScrollPositionContextProvider(props: ScrollPositionContextProps) } }, [locationType]); + const scrollIntoView = useCallback((rect: DOMRect) => { + scrollViewRef.current?.scrollIntoView(rect); + }, []); + const value = useMemo( () => ({ scrollPositions, @@ -66,6 +71,7 @@ export function ScrollPositionContextProvider(props: ScrollPositionContextProps) spacePreAllocationViewRef, saveScrollPosition, resetScrollPositions, + scrollIntoView, }), [saveScrollPosition, resetScrollPositions], ); |
