Skip to content

[CP Staging] Categories - Checkmark appears briefly next to the toggle after exiting selection mode #61906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/SelectionList/BaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function BaseListItem<TItem extends ListItem>({
hoverStyle,
onLongPressRow,
testID,
shouldUseDefaultRightHandSideCheckmark = true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder though if there is a better long term solution than this one? @daledah @thelullabyy

}: BaseListItemProps<TItem>) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -125,7 +126,7 @@ function BaseListItem<TItem extends ListItem>({
>
{typeof children === 'function' ? children(hovered) : children}

{!canSelectMultiple && !!item.isSelected && !rightHandSideComponent && (
{!canSelectMultiple && !!item.isSelected && !rightHandSideComponent && shouldUseDefaultRightHandSideCheckmark && (
<View
style={[styles.flexRow, styles.alignItemsCenter, styles.ml3]}
accessible={false}
Expand Down
2 changes: 2 additions & 0 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ function BaseSelectionList<TItem extends ListItem>(
fixedNumItemsForLoader,
loaderSpeed,
errorText,
shouldUseDefaultRightHandSideCheckmark,
}: SelectionListProps<TItem>,
ref: ForwardedRef<SelectionListHandle>,
) {
Expand Down Expand Up @@ -568,6 +569,7 @@ function BaseSelectionList<TItem extends ListItem>(
shouldAnimateInHighlight: isItemHighlighted,
...item,
}}
shouldUseDefaultRightHandSideCheckmark={shouldUseDefaultRightHandSideCheckmark}
index={index}
isFocused={isItemFocused}
isDisabled={isDisabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function BaseSelectionListItemRenderer<TItem extends ListItem>({
titleStyles,
singleExecution,
titleContainerStyles,
shouldUseDefaultRightHandSideCheckmark,
}: BaseSelectionListItemRendererProps<TItem>) {
const handleOnCheckboxPress = () => {
if (isReportListItemType(item)) {
Expand Down Expand Up @@ -92,6 +93,7 @@ function BaseSelectionListItemRenderer<TItem extends ListItem>({
wrapperStyle={wrapperStyle}
titleStyles={titleStyles}
titleContainerStyles={titleContainerStyles}
shouldUseDefaultRightHandSideCheckmark={shouldUseDefaultRightHandSideCheckmark}
/>
{item.footerContent && item.footerContent}
</>
Expand Down
2 changes: 2 additions & 0 deletions src/components/SelectionList/TableListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function TableListItem<TItem extends ListItem>({
onLongPressRow,
shouldSyncFocus,
titleContainerStyles,
shouldUseDefaultRightHandSideCheckmark,
}: TableListItemProps<TItem>) {
const styles = useThemeStyles();
const theme = useTheme();
Expand Down Expand Up @@ -80,6 +81,7 @@ function TableListItem<TItem extends ListItem>({
onFocus={onFocus}
shouldSyncFocus={shouldSyncFocus}
hoverStyle={item.isSelected && styles.activeComponentBG}
shouldUseDefaultRightHandSideCheckmark={shouldUseDefaultRightHandSideCheckmark}
>
{(hovered) => (
<>
Expand Down
8 changes: 8 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ type ListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {

/** Styles applied for the title container of the list item */
titleContainerStyles?: StyleProp<ViewStyle>;

/** Whether to show the default right hand side checkmark */
shouldUseDefaultRightHandSideCheckmark?: boolean;
};

type BaseListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
Expand All @@ -372,6 +375,8 @@ type BaseListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
shouldDisplayRBR?: boolean;
/** Test ID of the component. Used to locate this view in end-to-end tests. */
testID?: string;
/** Whether to show the default right hand side checkmark */
shouldUseDefaultRightHandSideCheckmark?: boolean;
};

type UserListItemProps<TItem extends ListItem> = ListItemProps<TItem> & {
Expand Down Expand Up @@ -734,6 +739,9 @@ type SelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {

/** Error text to display */
errorText?: string;

/** Whether to show the default right hand side checkmark */
shouldUseDefaultRightHandSideCheckmark?: boolean;
} & TRightHandSideComponent<TItem>;

type SelectionListHandle = {
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 @@ -798,6 +798,7 @@ function WorkspaceMembersPage({personalDetails, route, policy, currentUserPerson
sections={[{data: filteredData, isDisabled: false}]}
selectedItemKeys={selectedEmployees}
ListItem={TableListItem}
shouldUseDefaultRightHandSideCheckmark={false}
turnOnSelectionModeOnLongPress={isPolicyAdmin}
onTurnOnSelectionMode={(item) => item && toggleUser(item?.accountID)}
shouldUseUserSkeletonView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
turnOnSelectionModeOnLongPress={isSmallScreenWidth}
onTurnOnSelectionMode={(item) => item && toggleCategory(item)}
sections={[{data: filteredCategoryList, isDisabled: false}]}
shouldUseDefaultRightHandSideCheckmark={false}
selectedItemKeys={selectedCategories}
onCheckboxPress={toggleCategory}
onSelectRow={navigateToCategorySettings}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ function PolicyDistanceRatesPage({
turnOnSelectionModeOnLongPress
onTurnOnSelectionMode={(item) => item && toggleRate(item)}
sections={[{data: filteredDistanceRatesList, isDisabled: false}]}
shouldUseDefaultRightHandSideCheckmark={false}
selectedItemKeys={selectedDistanceRates}
onCheckboxPress={toggleRate}
onSelectRow={openRateDetails}
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/perDiem/WorkspacePerDiemPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ function WorkspacePerDiemPage({route}: WorkspacePerDiemPageProps) {
turnOnSelectionModeOnLongPress
onTurnOnSelectionMode={(item) => item && toggleSubRate(item)}
sections={[{data: filteredSubRatesList, isDisabled: false}]}
shouldUseDefaultRightHandSideCheckmark={false}
selectedItemKeys={selectedPerDiem.map((item) => item.subRateID)}
onCheckboxPress={toggleSubRate}
onSelectRow={openSubRateDetails}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ function ReportFieldsListValuesPage({
turnOnSelectionModeOnLongPress={!hasAccountingConnections}
onTurnOnSelectionMode={(item) => item && toggleValue(item)}
sections={sections}
shouldUseDefaultRightHandSideCheckmark={false}
onCheckboxPress={toggleValue}
onSelectRow={openListValuePage}
onSelectAll={toggleAllValues}
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {
turnOnSelectionModeOnLongPress={!isMultiLevelTags}
onTurnOnSelectionMode={(item) => item && toggleTag(item)}
sections={[{data: filteredTagList, isDisabled: false}]}
shouldUseDefaultRightHandSideCheckmark={false}
selectedItemKeys={selectedTags}
onCheckboxPress={toggleTag}
onSelectRow={navigateToTagSettings}
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/tags/WorkspaceViewTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
turnOnSelectionModeOnLongPress
onTurnOnSelectionMode={(item) => item && toggleTag(item)}
sections={sections}
shouldUseDefaultRightHandSideCheckmark={false}
onCheckboxPress={toggleTag}
onSelectRow={navigateToTagSettings}
onSelectAll={toggleAllTags}
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/taxes/WorkspaceTaxesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ function WorkspaceTaxesPage({
turnOnSelectionModeOnLongPress
onTurnOnSelectionMode={(item) => item && toggleTax(item)}
sections={[{data: filteredTaxesList, isDisabled: false}]}
shouldUseDefaultRightHandSideCheckmark={false}
selectedItemKeys={selectedTaxesIDs}
onCheckboxPress={toggleTax}
onSelectRow={navigateToEditTaxRate}
Expand Down