Skip to content
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

Fix checkbox outline in TaskView #28543

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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/UserListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ function UserListItem({item, isFocused = false, showTooltip, onSelectRow, onDism
hoverStyle={styles.hoveredComponentBG}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
<View style={styles.checkboxPressable}>
<View style={StyleUtils.getCheckboxPressableStyle()}>
<View
style={[
StyleUtils.getCheckboxContainerStyle(20, 4),
StyleUtils.getCheckboxContainerStyle(20),
Copy link
Contributor Author

@Nikhil-Vats Nikhil-Vats Sep 30, 2023

Choose a reason for hiding this comment

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

@jjcoffee I made 6px default border-radius for pressable and 4px for checkbox in StyleUtils so we don't have to pass them everywhere.

item.isSelected && styles.checkedContainer,
item.isSelected && styles.borderColorFocus,
item.isDisabled && styles.cursorDisabled,
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
Loading