mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
UX: Ensure currently selected account displays when Account Menu opens (#20166)
* UX: Ensure currently selected account displays when Account Menu opens * Jest tests
This commit is contained in:
parent
41bab4a6e1
commit
5db22ceb84
@ -1,4 +1,4 @@
|
||||
import React, { useState, useContext } from 'react';
|
||||
import React, { useState, useContext, useEffect, useRef } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classnames from 'classnames';
|
||||
|
||||
@ -87,6 +87,15 @@ export const AccountListItem = ({
|
||||
setAccountListItemMenuElement(ref);
|
||||
};
|
||||
|
||||
// If this is the selected item in the Account menu,
|
||||
// scroll the item into view
|
||||
const itemRef = useRef(null);
|
||||
useEffect(() => {
|
||||
if (selected) {
|
||||
itemRef.current?.scrollIntoView?.();
|
||||
}
|
||||
}, [itemRef, selected]);
|
||||
|
||||
const keyring = useSelector((state) =>
|
||||
findKeyringForAddress(state, identity.address),
|
||||
);
|
||||
@ -103,6 +112,7 @@ export const AccountListItem = ({
|
||||
'multichain-account-list-item--selected': selected,
|
||||
'multichain-account-list-item--connected': Boolean(connectedAvatar),
|
||||
})}
|
||||
ref={itemRef}
|
||||
onClick={() => {
|
||||
// Without this check, the account will be selected after
|
||||
// the account options menu closes
|
||||
|
Loading…
Reference in New Issue
Block a user