Skip to content

Commit

Permalink
feat: scroll to the active account (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvava authored Feb 7, 2025
1 parent fe60e3f commit 6a1a7b6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/pages/Accounts/components/AccountItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
ForwardedRef,
forwardRef,
useCallback,
useEffect,
useMemo,
useRef,
useState,
Expand Down Expand Up @@ -79,6 +80,18 @@ export const AccountItem = forwardRef(
const address = network ? getAddressForChain(network.chainId, account) : '';
const [cardHovered, setCardHovered] = useState(false);
const itemRef = useRef<HTMLDivElement>(null);
const firstPageload = useRef(true);

useEffect(() => {
if (isActive) {
const behavior = firstPageload.current ? 'instant' : 'smooth';
itemRef?.current?.scrollIntoView({
block: 'center',
behavior,
});
}
firstPageload.current = false;
}, [isActive]);

const toggle = useCallback(
(accountId: string) => {
Expand Down

0 comments on commit 6a1a7b6

Please sign in to comment.