From 2f2c1bb92739678c2a18ffebf64f3f24d620bf34 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 23 Oct 2022 21:40:03 +0530 Subject: [PATCH 1/7] fix: form draft for checkboxWithLabel --- src/components/CheckboxWithLabel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CheckboxWithLabel.js b/src/components/CheckboxWithLabel.js index 6ac3180e174c..cee24f33ab65 100644 --- a/src/components/CheckboxWithLabel.js +++ b/src/components/CheckboxWithLabel.js @@ -69,7 +69,7 @@ class CheckboxWithLabel extends React.Component { constructor(props) { super(props); - this.isChecked = props.defaultValue || props.isChecked; + this.isChecked = props.value || props.defaultValue || props.isChecked; this.LabelComponent = props.LabelComponent; this.defaultStyles = [styles.flexRow, styles.alignItemsCenter]; this.wrapperStyles = _.isArray(props.style) ? [...this.defaultStyles, ...props.style] : [...this.defaultStyles, props.style]; From 8b4559b0487c5c0fdb186c572065418c601c4f2a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 23 Oct 2022 21:42:38 +0530 Subject: [PATCH 2/7] feat: remove drafts for T&C --- src/pages/ReimbursementAccount/BankAccountManualStep.js | 1 - src/pages/settings/Payments/AddDebitCardPage.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/BankAccountManualStep.js b/src/pages/ReimbursementAccount/BankAccountManualStep.js index cdd93d80d077..d5f58071dc12 100644 --- a/src/pages/ReimbursementAccount/BankAccountManualStep.js +++ b/src/pages/ReimbursementAccount/BankAccountManualStep.js @@ -122,7 +122,6 @@ class BankAccountManualStep extends React.Component { )} defaultValue={ReimbursementAccountUtils.getDefaultStateForField(this.props, 'acceptTerms', false)} - shouldSaveDraft /> diff --git a/src/pages/settings/Payments/AddDebitCardPage.js b/src/pages/settings/Payments/AddDebitCardPage.js index 2e100bb78ba5..c60e261ce9c8 100644 --- a/src/pages/settings/Payments/AddDebitCardPage.js +++ b/src/pages/settings/Payments/AddDebitCardPage.js @@ -191,7 +191,6 @@ class DebitCardPage extends Component { )} style={[styles.mt4]} - shouldSaveDraft /> From 37066cd685f09045ce2a483255a539a0686d583b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 23 Oct 2022 21:43:49 +0530 Subject: [PATCH 3/7] remove dead props passed to checkbox --- src/components/CheckboxWithLabel.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/CheckboxWithLabel.js b/src/components/CheckboxWithLabel.js index cee24f33ab65..5aaa514acbb2 100644 --- a/src/components/CheckboxWithLabel.js +++ b/src/components/CheckboxWithLabel.js @@ -92,8 +92,6 @@ class CheckboxWithLabel extends React.Component { label={this.props.label} hasError={Boolean(this.props.errorText)} forwardedRef={this.props.forwardedRef} - inputID={this.props.inputID} - shouldSaveDraft={this.props.shouldSaveDraft} /> Date: Sun, 23 Oct 2022 21:47:44 +0530 Subject: [PATCH 4/7] fix: propTypes --- src/components/CheckboxWithLabel.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/CheckboxWithLabel.js b/src/components/CheckboxWithLabel.js index 5aaa514acbb2..c6340ac8c964 100644 --- a/src/components/CheckboxWithLabel.js +++ b/src/components/CheckboxWithLabel.js @@ -40,17 +40,14 @@ const propTypes = { /** Error text to display */ errorText: PropTypes.string, + /** Value for checkbox. This prop is intended to be set by Form.js only */ + value: PropTypes.bool, + /** The default value for the checkbox */ defaultValue: PropTypes.bool, /** React ref being forwarded to the Checkbox input */ forwardedRef: PropTypes.func, - - /** The ID used to uniquely identify the input in a Form */ - inputID: PropTypes.string, - - /** Saves a draft of the input value when used in a form */ - shouldSaveDraft: PropTypes.bool, }; const defaultProps = { From 41b545f741f4771d99cd42030e86ccff7669bca3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 23 Oct 2022 21:49:18 +0530 Subject: [PATCH 5/7] fix: defaultProps --- src/components/CheckboxWithLabel.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/CheckboxWithLabel.js b/src/components/CheckboxWithLabel.js index c6340ac8c964..628ffe1d55b9 100644 --- a/src/components/CheckboxWithLabel.js +++ b/src/components/CheckboxWithLabel.js @@ -51,13 +51,12 @@ const propTypes = { }; const defaultProps = { - inputID: undefined, style: [], label: undefined, LabelComponent: undefined, errorText: '', - shouldSaveDraft: false, isChecked: false, + value: false, defaultValue: false, forwardedRef: () => {}, }; From 6c69f154ac3c9678729ab42e6592e50b444f0745 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 24 Oct 2022 00:07:38 +0530 Subject: [PATCH 6/7] revert remove form props --- src/components/CheckboxWithLabel.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/CheckboxWithLabel.js b/src/components/CheckboxWithLabel.js index 628ffe1d55b9..cd55856b1bff 100644 --- a/src/components/CheckboxWithLabel.js +++ b/src/components/CheckboxWithLabel.js @@ -48,13 +48,23 @@ const propTypes = { /** React ref being forwarded to the Checkbox input */ forwardedRef: PropTypes.func, + + /** The ID used to uniquely identify the input in a Form */ + /* eslint-disable-next-line react/no-unused-prop-types */ + inputID: PropTypes.string, + + /** eslint-disable-next-line react/no-unused-prop-types */ + /* eslint-disable-next-line react/no-unused-prop-types */ + shouldSaveDraft: PropTypes.bool, }; const defaultProps = { + inputID: undefined, style: [], label: undefined, LabelComponent: undefined, errorText: '', + shouldSaveDraft: false, isChecked: false, value: false, defaultValue: false, From 50c66ddfd1c4ee6a39575ee99acb3437b6993990 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 23 Oct 2022 22:34:51 +0300 Subject: [PATCH 7/7] fix: prop comment Co-authored-by: Rajat Parashar --- src/components/CheckboxWithLabel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CheckboxWithLabel.js b/src/components/CheckboxWithLabel.js index cd55856b1bff..8ee5c6712a6e 100644 --- a/src/components/CheckboxWithLabel.js +++ b/src/components/CheckboxWithLabel.js @@ -53,7 +53,7 @@ const propTypes = { /* eslint-disable-next-line react/no-unused-prop-types */ inputID: PropTypes.string, - /** eslint-disable-next-line react/no-unused-prop-types */ + /** Saves a draft of the input value when used in a form */ /* eslint-disable-next-line react/no-unused-prop-types */ shouldSaveDraft: PropTypes.bool, };