diff --git a/src/components/SelectionList/BaseSelectionList.js b/src/components/SelectionList/BaseSelectionList.js index 046b64e9e5c0..d5cd96b9b029 100644 --- a/src/components/SelectionList/BaseSelectionList.js +++ b/src/components/SelectionList/BaseSelectionList.js @@ -11,7 +11,7 @@ import CONST from '../../CONST'; import variables from '../../styles/variables'; import {propTypes as selectionListPropTypes} from './selectionListPropTypes'; import RadioListItem from './RadioListItem'; -import CheckboxListItem from './CheckboxListItem'; +import UserListItem from './UserListItem'; import useKeyboardShortcut from '../../hooks/useKeyboardShortcut'; import SafeAreaConsumer from '../SafeAreaConsumer'; import withKeyboardState, {keyboardStatePropTypes} from '../withKeyboardState'; @@ -242,16 +242,20 @@ function BaseSelectionList({ }; const renderItem = ({item, index, section}) => { + const normalizedIndex = index + lodashGet(section, 'indexOffset', 0); const isDisabled = section.isDisabled; - const isFocused = !isDisabled && focusedIndex === index + lodashGet(section, 'indexOffset', 0); + const isFocused = !isDisabled && focusedIndex === normalizedIndex; + // We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade. + const showTooltip = normalizedIndex < 10; if (canSelectMultiple) { return ( - selectRow(item, index)} onDismissError={onDismissError} + showTooltip={showTooltip} /> ); } diff --git a/src/components/SelectionList/CheckboxListItem.js b/src/components/SelectionList/UserListItem.js similarity index 57% rename from src/components/SelectionList/CheckboxListItem.js rename to src/components/SelectionList/UserListItem.js index 256182a38e8b..dd90fc750510 100644 --- a/src/components/SelectionList/CheckboxListItem.js +++ b/src/components/SelectionList/UserListItem.js @@ -5,7 +5,7 @@ import lodashGet from 'lodash/get'; import PressableWithFeedback from '../Pressable/PressableWithFeedback'; import styles from '../../styles/styles'; import Text from '../Text'; -import {checkboxListItemPropTypes} from './selectionListPropTypes'; +import {userListItemPropTypes} from './selectionListPropTypes'; import Avatar from '../Avatar'; import OfflineWithFeedback from '../OfflineWithFeedback'; import CONST from '../../CONST'; @@ -13,10 +13,39 @@ import * as StyleUtils from '../../styles/StyleUtils'; import Icon from '../Icon'; import * as Expensicons from '../Icon/Expensicons'; import themeColors from '../../styles/themes/default'; +import Tooltip from '../Tooltip'; +import UserDetailsTooltip from '../UserDetailsTooltip'; -function CheckboxListItem({item, isFocused = false, onSelectRow, onDismissError = () => {}}) { +function UserListItem({item, isFocused = false, showTooltip, onSelectRow, onDismissError = () => {}}) { const hasError = !_.isEmpty(item.errors); + const avatar = ( + + ); + + const text = ( + + {item.text} + + ); + + const alternateText = ( + + {item.alternateText} + + ); + return ( onDismissError(item)} @@ -53,29 +82,20 @@ function CheckboxListItem({item, isFocused = false, onSelectRow, onDismissError /> )} - {Boolean(item.avatar) && ( - - )} - - - {item.text} - - {Boolean(item.alternateText) && ( - - {item.alternateText} - - )} + {avatar} + + ) : ( + avatar + ))} + + {showTooltip ? {text} : text} + {Boolean(item.alternateText) && (showTooltip ? {alternateText} : alternateText)} {Boolean(item.rightElement) && item.rightElement} @@ -83,7 +103,7 @@ function CheckboxListItem({item, isFocused = false, onSelectRow, onDismissError ); } -CheckboxListItem.displayName = 'CheckboxListItem'; -CheckboxListItem.propTypes = checkboxListItemPropTypes; +UserListItem.displayName = 'UserListItem'; +UserListItem.propTypes = userListItemPropTypes; -export default CheckboxListItem; +export default UserListItem; diff --git a/src/components/SelectionList/selectionListPropTypes.js b/src/components/SelectionList/selectionListPropTypes.js index 9adf42833ebc..501de8314934 100644 --- a/src/components/SelectionList/selectionListPropTypes.js +++ b/src/components/SelectionList/selectionListPropTypes.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import _ from 'underscore'; import CONST from '../../CONST'; -const checkboxListItemPropTypes = { +const userListItemPropTypes = { /** The section list item */ item: PropTypes.shape({ /** Text to display */ @@ -46,6 +46,9 @@ const checkboxListItemPropTypes = { /** Whether this item is focused (for arrow key controls) */ isFocused: PropTypes.bool, + /** Whether this item should show Tooltip */ + showTooltip: PropTypes.bool.isRequired, + /** Callback to fire when the item is pressed */ onSelectRow: PropTypes.func.isRequired, @@ -90,7 +93,7 @@ const propTypes = { indexOffset: PropTypes.number, /** Array of options */ - data: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape(checkboxListItemPropTypes.item), PropTypes.shape(radioListItemPropTypes.item)])), + data: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape(userListItemPropTypes.item), PropTypes.shape(radioListItemPropTypes.item)])), /** Whether this section items disabled for selection */ isDisabled: PropTypes.bool, @@ -158,4 +161,4 @@ const propTypes = { showConfirmButton: PropTypes.bool, }; -export {propTypes, radioListItemPropTypes, checkboxListItemPropTypes}; +export {propTypes, radioListItemPropTypes, userListItemPropTypes}; diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index d598f90e4326..22c0a2aca2c4 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -307,6 +307,7 @@ function WorkspaceMembersPage(props) { result.push({ keyForList: accountID, + accountID: Number(accountID), isSelected: _.contains(selectedEmployees, Number(accountID)), isDisabled: accountID === props.session.accountID || details.login === props.policy.owner || policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, text: props.formatPhoneNumber(details.displayName),