-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
17051 - migrated Checkbox to PressableWithFeedback #20257
Changes from 1 commit
ac6b7d7
73859b7
0690682
d16f038
46c4130
d25865e
5d1e5ed
4917bf7
56b01f4
a63eee4
0426c25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import React from 'react'; | ||
import {View, Pressable} from 'react-native'; | ||
import {View} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import styles from '../styles/styles'; | ||
import themeColors from '../styles/themes/default'; | ||
import stylePropTypes from '../styles/stylePropTypes'; | ||
import Icon from './Icon'; | ||
import * as Expensicons from './Icon/Expensicons'; | ||
import PressableWithFeedback from './Pressable/PressableWithFeedback'; | ||
|
||
const propTypes = { | ||
/** Whether checkbox is checked */ | ||
|
@@ -34,6 +35,9 @@ const propTypes = { | |
|
||
/** A ref to forward to the Pressable */ | ||
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.instanceOf(React.Component)})]), | ||
|
||
/** A ref to forward to the Pressable */ | ||
accessibilityLabel: PropTypes.string, | ||
}; | ||
|
||
const defaultProps = { | ||
|
@@ -45,6 +49,7 @@ const defaultProps = { | |
forwardedRef: undefined, | ||
children: null, | ||
onMouseDown: undefined, | ||
accessibilityLabel: 'checkbox', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the default accessibilityLabel be empty string? Since it will not be useful to read out checkbox without context in case of default is not useful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I will change that |
||
}; | ||
|
||
class Checkbox extends React.Component { | ||
|
@@ -95,20 +100,23 @@ class Checkbox extends React.Component { | |
|
||
render() { | ||
return ( | ||
<Pressable | ||
<PressableWithFeedback | ||
disabled={this.props.disabled} | ||
onPress={this.firePressHandlerOnClick} | ||
onMouseDown={this.props.onMouseDown} | ||
onFocus={this.onFocus} | ||
onBlur={this.onBlur} | ||
ref={this.props.forwardedRef} | ||
onPressOut={this.onBlur} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Skalakid What is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Skalakid any update on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abdulrahuman5196 Hey, sorry for the late response, I just fixed this by merging with the main ;) I think it was added after merging with main, now it's gone |
||
style={this.props.style} | ||
style={[this.props.style, styles.userSelectNone]} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And any reason to not allow user to select the checkbox text? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously after double-clicking the checkbox icon was somehow selectable, now after I merged the latest main I can't reproduce it so I can remove it |
||
onKeyDown={this.handleSpaceKey} | ||
accessibilityRole="checkbox" | ||
accessibilityState={{ | ||
checked: this.props.isChecked, | ||
}} | ||
accessibilityLabel={this.props.accessibilityLabel} | ||
hoverDimmingValue={1} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we remove this? Since currently the default for hoverDimmingValue is 1? |
||
pressDimmingValue={1} | ||
> | ||
{this.props.children ? ( | ||
this.props.children | ||
|
@@ -133,7 +141,7 @@ class Checkbox extends React.Component { | |
)} | ||
</View> | ||
)} | ||
</Pressable> | ||
</PressableWithFeedback> | ||
); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Skalakid Wrong type comment here. Could you update this?