Skip to content

Commit

Permalink
Refactor isDisabledCheckbox
Browse files Browse the repository at this point in the history
  • Loading branch information
filip-solecki committed Mar 13, 2024
1 parent d772221 commit d696446
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/components/SelectionList/BaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ function BaseListItem<TItem extends ListItem>({
const StyleUtils = useStyleUtils();
const {hovered, bind} = useHover();

const isDisabledCheckbox = item.isDisabledCheckbox === undefined || item.isDisabledCheckbox;

const rightHandSideComponentRender = () => {
if (canSelectMultiple || !rightHandSideComponent) {
return null;
Expand Down Expand Up @@ -83,9 +81,9 @@ function BaseListItem<TItem extends ListItem>({
accessibilityLabel={item.text ?? ''}
role={CONST.ROLE.BUTTON}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
disabled={isDisabled || !isDisabledCheckbox}
disabled={isDisabled || item.isDisabledCheckbox}
onPress={handleCheckboxPress}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), !isDisabledCheckbox && styles.cursorDisabled]}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled]}
>
<View style={selectMultipleStyle}>
{item.isSelected && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function BaseSelectionList<TItem extends ListItem>(

// If disabled, add to the disabled indexes array
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (!!section.isDisabled || item.isDisabled || item.isDisabledCheckbox === false) {
if (!!section.isDisabled || item.isDisabled || item.isDisabledCheckbox) {
disabledOptionsIndexes.push(disabledIndex);
}
disabledIndex += 1;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/taxes/WorkspaceTaxesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function WorkspaceTaxesPage({policy, route}: WorkspaceTaxesPageProps) {
alternateText: textForDefault(key),
keyForList: key,
isSelected: !!selectedTaxesIDs.includes(key),
isDisabledCheckbox: key !== defaultExternalID,
isDisabledCheckbox: key === defaultExternalID,
rightElement: (
<View style={styles.flexRow}>
<Text style={[styles.disabledText, styles.alignSelfCenter]}>
Expand Down

0 comments on commit d696446

Please sign in to comment.