Skip to content

Commit

Permalink
Merge pull request #28543 from Nikhil-Vats/27872_fix_checkbox_outline
Browse files Browse the repository at this point in the history
Fix checkbox outline in TaskView
  • Loading branch information
deetergp authored Oct 2, 2023
2 parents 7dae708 + 451218a commit 0f42aea
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function Checkbox(props) {
onPress={firePressHandlerOnClick}
onMouseDown={props.onMouseDown}
ref={props.forwardedRef}
style={[props.style, styles.checkboxPressable]}
style={[props.style, StyleUtils.getCheckboxPressableStyle(props.containerBorderRadius + 2)]} // to align outline on focus, border-radius of pressable should be 2px more than Checkbox
onKeyDown={handleSpaceKey}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.CHECKBOX}
accessibilityState={{checked: props.isChecked}}
Expand Down
4 changes: 2 additions & 2 deletions src/components/SelectionList/BaseListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ function BaseListItem({item, isFocused = false, isDisabled = false, showTooltip,
]}
>
{canSelectMultiple && (
<View style={styles.checkboxPressable}>
<View style={StyleUtils.getCheckboxPressableStyle()}>
<View
style={[
StyleUtils.getCheckboxContainerStyle(20, 4),
StyleUtils.getCheckboxContainerStyle(20),
styles.mr3,
item.isSelected && styles.checkedContainer,
item.isSelected && styles.borderColorFocus,
Expand Down
16 changes: 15 additions & 1 deletion src/styles/StyleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1147,10 +1147,23 @@ function getDisabledLinkStyles(isDisabled = false): ViewStyle | CSSProperties {
};
}

/**
* Returns the checkbox pressable style
*/
function getCheckboxPressableStyle(borderRadius = 6): ViewStyle | CSSProperties {
return {
padding: 2,
justifyContent: 'center',
alignItems: 'center',
// eslint-disable-next-line object-shorthand
borderRadius: borderRadius,
};
}

/**
* Returns the checkbox container style
*/
function getCheckboxContainerStyle(size: number, borderRadius: number): ViewStyle | CSSProperties {
function getCheckboxContainerStyle(size: number, borderRadius = 4): ViewStyle | CSSProperties {
return {
backgroundColor: themeColors.componentBG,
height: size,
Expand Down Expand Up @@ -1287,6 +1300,7 @@ export {
getWrappingStyle,
getMenuItemTextContainerStyle,
getDisabledLinkStyles,
getCheckboxPressableStyle,
getCheckboxContainerStyle,
getDropDownButtonHeight,
getAmountFontSizeAndLineHeight,
Expand Down
7 changes: 0 additions & 7 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2448,13 +2448,6 @@ const styles = (theme) => ({
alignItems: 'center',
},

checkboxPressable: {
borderRadius: 6,
padding: 2,
justifyContent: 'center',
alignItems: 'center',
},

checkedContainer: {
backgroundColor: theme.checkBox,
},
Expand Down

0 comments on commit 0f42aea

Please sign in to comment.