diff options
Diffstat (limited to 'gui/src')
3 files changed, 9 insertions, 3 deletions
diff --git a/gui/src/renderer/components/SearchBar.tsx b/gui/src/renderer/components/SearchBar.tsx index c70e5c3de1..da2de73af0 100644 --- a/gui/src/renderer/components/SearchBar.tsx +++ b/gui/src/renderer/components/SearchBar.tsx @@ -89,7 +89,7 @@ export default function SearchBar(props: ISearchBarProps) { useEffect(() => { if (!props.disableAutoFocus) { - inputRef.current?.focus(); + inputRef.current?.focus({ preventScroll: true }); } }, []); 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], ); |
