Skip to content

Commit

Permalink
Update perf-tests x3
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhenjaHorbach committed Mar 30, 2024
1 parent 9eba416 commit defd731
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 88 deletions.
138 changes: 64 additions & 74 deletions src/components/SelectionList/BaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,85 +58,75 @@ function BaseListItem<TItem extends ListItem>({
};

return (
<OfflineWithFeedback
onClose={() => onDismissError(item)}
pendingAction={pendingAction}
errors={errors}
errorRowStyles={styles.ph5}
style={containerStyle}
<PressableWithFeedback
// eslint-disable-next-line react/jsx-props-no-spreading
{...bind}
onPress={() => onSelectRow(item)}
disabled={isDisabled}
accessibilityLabel={item.text ?? ''}
hoverDimmingValue={1}
hoverStyle={!item.isDisabled && !item.isSelected && styles.hoveredComponentBG}
onMouseDown={shouldPreventDefaultFocusOnSelectRow ? (e) => e.preventDefault() : undefined}
nativeID={keyForList ?? ''}
style={pressableStyle}
>
<PressableWithFeedback
// eslint-disable-next-line react/jsx-props-no-spreading
{...bind}
onPress={() => onSelectRow(item)}
disabled={isDisabled}
accessibilityLabel={item.text ?? ''}
role={CONST.ROLE.BUTTON}
hoverDimmingValue={1}
hoverStyle={!item.isDisabled && !item.isSelected && styles.hoveredComponentBG}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
onMouseDown={shouldPreventDefaultFocusOnSelectRow ? (e) => e.preventDefault() : undefined}
nativeID={keyForList ?? ''}
style={pressableStyle}
>
<View style={wrapperStyle}>
{canSelectMultiple && checkmarkPosition === CONST.DIRECTION.LEFT && (
<PressableWithFeedback
accessibilityLabel={item.text ?? ''}
role={CONST.ROLE.BUTTON}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
disabled={isDisabled || item.isDisabledCheckbox}
onPress={handleCheckboxPress}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled, styles.mr3]}
>
<View style={selectMultipleStyle}>
{item.isSelected && (
<Icon
src={Expensicons.Checkmark}
fill={theme.textLight}
height={14}
width={14}
/>
)}
</View>
</PressableWithFeedback>
)}

{typeof children === 'function' ? children(hovered) : children}

{canSelectMultiple && checkmarkPosition === CONST.DIRECTION.RIGHT && (
<PressableWithFeedback
onPress={handleCheckboxPress}
disabled={isDisabled}
role={CONST.ROLE.BUTTON}
accessibilityLabel={item.text ?? ''}
style={[styles.ml2, styles.optionSelectCircle]}
>
<SelectCircle
isChecked={item.isSelected ?? false}
selectCircleStyles={styles.ml0}
/>
</PressableWithFeedback>
)}

{!canSelectMultiple && item.isSelected && !rightHandSideComponent && (
<View
style={[styles.flexRow, styles.alignItemsCenter, styles.ml3]}
accessible={false}
>
<View>
<View style={wrapperStyle}>
{canSelectMultiple && checkmarkPosition === CONST.DIRECTION.LEFT && (
<PressableWithFeedback
accessibilityLabel={item.text ?? ''}
role={CONST.ROLE.BUTTON}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
disabled={isDisabled || item.isDisabledCheckbox}
onPress={handleCheckboxPress}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled, styles.mr3]}
>
<View style={selectMultipleStyle}>
{item.isSelected && (
<Icon
src={Expensicons.Checkmark}
fill={theme.success}
fill={theme.textLight}
height={14}
width={14}
/>
</View>
)}
</View>
</PressableWithFeedback>
)}

{typeof children === 'function' ? children(hovered) : children}

{canSelectMultiple && checkmarkPosition === CONST.DIRECTION.RIGHT && (
<PressableWithFeedback
onPress={handleCheckboxPress}
disabled={isDisabled}
role={CONST.ROLE.BUTTON}
accessibilityLabel={item.text ?? ''}
style={[styles.ml2, styles.optionSelectCircle]}
>
<SelectCircle
isChecked={item.isSelected ?? false}
selectCircleStyles={styles.ml0}
/>
</PressableWithFeedback>
)}

{!canSelectMultiple && item.isSelected && !rightHandSideComponent && (
<View
style={[styles.flexRow, styles.alignItemsCenter, styles.ml3]}
accessible={false}
>
<View>
<Icon
src={Expensicons.Checkmark}
fill={theme.success}
/>
</View>
)}
{rightHandSideComponentRender()}
</View>
{FooterComponent}
</PressableWithFeedback>
</OfflineWithFeedback>
</View>
)}
{rightHandSideComponentRender()}
</View>
{FooterComponent}
</PressableWithFeedback>
);
}

Expand Down
12 changes: 0 additions & 12 deletions src/components/SelectionList/TableListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ function TableListItem({
return (
<BaseListItem
item={item}
pressableStyle={[[styles.selectionListPressableItemWrapper, item.isSelected && styles.activeComponentBG, isFocused && styles.sidebarLinkActive]]}
wrapperStyle={[styles.flexRow, styles.flex1, styles.justifyContentBetween, styles.userSelectNone, styles.alignItemsCenter]}
containerStyle={styles.mb3}
selectMultipleStyle={[StyleUtils.getCheckboxContainerStyle(20), StyleUtils.getMultiselectListStyles(!!item.isSelected, !!item.isDisabled)]}
isFocused={isFocused}
isDisabled={isDisabled}
showTooltip={showTooltip}
Expand Down Expand Up @@ -66,14 +62,6 @@ function TableListItem({
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={item.text ?? ''}
style={[
styles.optionDisplayName,
isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText,
styles.sidebarLinkTextBold,
styles.pre,
item.alternateText ? styles.mb1 : null,
styles.justifyContentCenter,
]}
/>
{!!item.alternateText && (
<TextWithTooltip
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/WorkspaceMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ function WorkspaceMembersPage({
}}
/>
<View style={[styles.w100, styles.flex1]}>
//
<SelectionList
ref={selectionListRef}
canSelectMultiple={isPolicyAdmin}
Expand Down
2 changes: 1 addition & 1 deletion tests/perf-test/ReportActionCompose.perf-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jest.mock('@react-navigation/native', () => {
navigate: jest.fn(),
addListener: () => jest.fn(),
}),
useIsFocused: () => true,
useIsFocused: () => true,
} as typeof Navigation;
});

Expand Down
2 changes: 1 addition & 1 deletion tests/perf-test/SignInPage.perf-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jest.mock('@react-navigation/native', () => {
return {
...actualNav,
useFocusEffect: jest.fn(),
useIsFocused: () => true,
useIsFocused: () => true,
useRoute: () => jest.fn(),
useNavigation: () => ({
navigate: jest.fn(),
Expand Down

0 comments on commit defd731

Please sign in to comment.