Skip to content

Commit cc193d3

Browse files
authored
Merge pull request Expensify#89708 from software-mansion-labs/fix/disabled-selected-item-button
[CP Staging] Make selection button clickable in SelectableListItem when item is selected but disabled
2 parents 8f67bd6 + d57c8d6 commit cc193d3

5 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/components/SelectionList/BaseSelectionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ function BaseSelectionList<TItem extends ListItem>({
347347
};
348348

349349
const renderItem: ListRenderItem<TItem> = ({item, index}: ListRenderItemInfo<TItem>) => {
350-
const isItemDisabled = isDisabled || item.isDisabled;
351350
const selected = isItemSelected(item);
351+
const isItemDisabled = isDisabled || (!!item.isDisabled && !selected);
352352
const isItemFocused = (!isDisabled || selected) && focusedIndex === index;
353353
const isItemVisuallyFocused = isItemFocused && (shouldHighlightInitiallyFocusedItem || isKeyboardNavigating);
354354
const isItemHighlighted = !!itemsToHighlight?.has(item.keyForList);

src/components/SelectionList/ListItem/BaseListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function BaseListItem<TItem extends ListItem>({
199199
isNested
200200
hoverDimmingValue={1}
201201
pressDimmingValue={item.isInteractive === false ? 1 : variables.pressDimValue}
202-
hoverStyle={!shouldDisableHoverStyle ? [!item.isDisabled && item.isInteractive !== false && styles.hoveredComponentBG, hoverStyle] : undefined}
202+
hoverStyle={!shouldDisableHoverStyle ? [(!item.isDisabled || item.isSelected) && item.isInteractive !== false && styles.hoveredComponentBG, hoverStyle] : undefined}
203203
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true, [CONST.INNER_BOX_SHADOW_ELEMENT]: shouldShowBlueBorderOnFocus}}
204204
onMouseDown={(e) => {
205205
if ((e?.target as HTMLElement)?.tagName === CONST.ELEMENT_NAME.INPUT) {

src/components/SelectionList/ListItem/InviteMemberListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function InviteMemberListItem<TItem extends ListItem>({
4747
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
4848
const accountID = !item.reportID ? item.accountID || firstItemIconID : undefined;
4949

50-
const ListItemWrapper = item.isDisabled ? BaseListItem : SelectableListItem;
50+
const ListItemWrapper = item.isDisabled && !item.isSelected ? BaseListItem : SelectableListItem;
5151

5252
return (
5353
<ListItemWrapper

src/components/SelectionList/ListItem/SelectableListItem.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ function SelectableListItem<TItem extends ListItem>({
4141
<ButtonComponent
4242
item={item}
4343
onSelectRow={onSelectionButtonPress ?? onSelectRow}
44-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- disabled if either of the optional booleans are true
45-
disabled={isDisabled || item.isDisabledCheckbox}
44+
disabled={!!isDisabled || !!item.isDisabledCheckbox}
4645
style={styles.ml3}
4746
/>
4847
{typeof rightHandSideComponent === 'function' ? rightHandSideComponent(item, isFocused) : rightHandSideComponent}
@@ -58,8 +57,7 @@ function SelectableListItem<TItem extends ListItem>({
5857
<ButtonComponent
5958
item={item}
6059
onSelectRow={onSelectionButtonPress ?? onSelectRow}
61-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- disabled if either of the optional booleans are true
62-
disabled={isDisabled || item.isDisabledCheckbox}
60+
disabled={!!isDisabled || item.isDisabledCheckbox}
6361
style={styles.mr3}
6462
/>
6563
{typeof children === 'function' ? children(hovered) : children}

src/components/SelectionList/SelectionListWithSections/BaseSelectionListWithSections.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ function BaseSelectionListWithSections<TItem extends ListItem>({
364364
case CONST.SECTION_LIST_ITEM_TYPE.ROW: {
365365
const isItemFocused = index === focusedIndex;
366366
const isItemVisuallyFocused = isItemFocused && (shouldHighlightInitiallyFocusedItem || isKeyboardNavigating);
367-
const isDisabled = !!item.isDisabled;
367+
const isDisabled = !!item.isDisabled && !item.isSelected;
368368

369369
return (
370370
<ListItemRenderer

0 commit comments

Comments
 (0)