Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pecanoro committed Oct 12, 2021
1 parent 976e0ca commit d953a31
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ import withWindowDimensions from '../withWindowDimensions';
class CheckboxWithTooltipForMobileWebAndNative extends React.Component {
constructor(props) {
super(props);
this.onPress = this.onPress.bind(this);
this.showGrowlAndTriggerOnPress = this.showGrowlAndTriggerOnPress.bind(this);
}

componentDidUpdate() {
if (this.props.toggleTooltip) {
Growl.show(this.props.text, CONST.GROWL.WARNING, 3000);
Growl.show(this.props.text, this.props.growlType, 3000);
}
}

/**
* Show warning modal on mobile devices since tooltips are not supported when checkbox is disabled.
*/
onPress() {
showGrowlAndTriggerOnPress() {
if (this.props.toggleTooltip) {
Growl.show(this.props.text, CONST.GROWL.WARNING, 3000);
Growl.show(this.props.text, this.props.growlType, 3000);
}
this.props.onPress();
}
Expand All @@ -34,7 +34,7 @@ class CheckboxWithTooltipForMobileWebAndNative extends React.Component {
<View style={this.props.style}>
<Checkbox
isChecked={this.props.isChecked}
onPress={this.onPress}
onPress={this.showGrowlAndTriggerOnPress}
/>
</View>
);
Expand All @@ -44,6 +44,4 @@ class CheckboxWithTooltipForMobileWebAndNative extends React.Component {
CheckboxWithTooltipForMobileWebAndNative.propTypes = propTypes;
CheckboxWithTooltipForMobileWebAndNative.defaultProps = defaultProps;

export default compose(
withWindowDimensions,
)(CheckboxWithTooltipForMobileWebAndNative);
export default withWindowDimensions(CheckboxWithTooltipForMobileWebAndNative);
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import PropTypes from 'prop-types';
import {windowDimensionsPropTypes} from '../withWindowDimensions';
import CONST from '../../CONST';
import stylePropTypes from '../../styles/stylePropTypes';

const propTypes = {
/** Whether the checkbox is checked */
Expand All @@ -17,8 +19,11 @@ const propTypes = {
/** Should the input be disabled */
disabled: PropTypes.bool,

/** Type of the growl to be displayed in case of mobile devices */
growlType: PropTypes.string,

/** Container styles */
style: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]),
style: stylePropTypes,

/** Props inherited from withWindowDimensions */
...windowDimensionsPropTypes,
Expand All @@ -28,6 +33,7 @@ const defaultProps = {
style: [],
disabled: false,
toggleTooltip: true,
growlType: CONST.GROWL.WARNING,
};

export {
Expand Down
4 changes: 1 addition & 3 deletions src/components/CheckboxWithTooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@ CheckboxWithTooltip.propTypes = propTypes;
CheckboxWithTooltip.defaultProps = defaultProps;
CheckboxWithTooltip.displayName = 'CheckboxWithTooltip';

export default compose(
withWindowDimensions,
)(CheckboxWithTooltip);
export default withWindowDimensions(CheckboxWithTooltip);
4 changes: 1 addition & 3 deletions src/components/CheckboxWithTooltip/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ CheckboxWithTooltip.propTypes = propTypes;
CheckboxWithTooltip.defaultProps = defaultProps;
CheckboxWithTooltip.displayName = 'CheckboxWithTooltip';

export default compose(
withWindowDimensions,
)(CheckboxWithTooltip);
export default withWindowDimensions(CheckboxWithTooltip);

0 comments on commit d953a31

Please sign in to comment.