-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix: save terms of service checkbox in draft #18479
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
Conversation
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
|
@pecanoro @aimane-chnaif One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
src/components/CheckboxWithLabel.js
Outdated
| if (!_.isUndefined(props.value)) { | ||
| this.isChecked = props.value; | ||
| } else if (!_.isUndefined(props.defaultValue)) { | ||
| this.isChecked = props.defaultValue; | ||
| } else { | ||
| this.isChecked = props.isChecked; | ||
| } |
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.
_.find() is more dry code?
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.
Sorry, what do you mean?
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.
this.isChecked = _.find([props.value, props.defaultValue, props.isChecked], value => _.isBoolean(value));
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.
Ah, this works. But I chose the if conditions because I thought it is more easier to understand what we are trying to achieve. But I'm happy to change it if you disagree.
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.
If you agree with my suggestion, let's apply that and add comment above. Comment is needed either way so that others don't do same mistake in the future.
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.
Sounds good!
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.
@aimane-chnaif Fixed.
src/components/Form.js
Outdated
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.
We can't use _.isBoolean here. Text input values are string.
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.
Nice catch @aimane-chnaif. Pushed with the revert.
src/components/Form.js
Outdated
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.
Let's say draftValue is null, defaultValue is 'xyz' in text input!
old logic returns 'xyz'
new logic returns null
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.
We should not change current text input logic but only checkbox logic.
Will this work?
if (_.isBoolean(this.props.draftValues[inputID])) {
defaultValue = this.props.draftValues[inputID];
} else {
defaultValue = this.props.draftValues[inputID] || child.props.defaultValue;
}
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.
This might work but I think its not very easy to understand / readable. Although, we can add a comment, but I think this can be improved. I can see lodash 4.0 has a isNil method which checks for null and undefined. But we're at a older version and can't use it.
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.
We're actually using underscore in this file. I'll see if it has something like nil
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.
Another case: '' || 'xyz'
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.
Hm... You're spot on. I'll make the changes that you suggested.
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.
Can you check what _isEmpty returns for null, undefined, '', 0, false/true?
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.
console.log(isBlank(null)); -> true
console.log(isBlank(undefined)); -> true
console.log(isBlank('')); -> true
console.log(isBlank(false)); -> false
console.log(isEmpty(null)); -> true
console.log(isEmpty(undefined)); -> true
console.log(isEmpty('')); -> true
console.log(isEmpty(false)); -> true
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.
isBlank is available in underscore.string only :)
src/components/Form.js
Outdated
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.
Let's add comment what's this for. And link to issue comment (not issue).
Same above
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.
Added.
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemchrome.movMobile Web - Safarimsafari.movDesktopdesktop.moviOSios.movAndroidandroid.mov |
aimane-chnaif
left a comment
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.
LGTM 🎉
@pecanoro all yours!
pecanoro
left a comment
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.
Did you test that the form component is still working fine? I tested adding a bank account and it should be fine, but making sure that you both tested it as well?
yes I tested already |
Co-authored-by: Rocio Perez-Cano <pecanoro@users.noreply.github.com>
aimane-chnaif
left a comment
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.
👍
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/pecanoro in version: 1.3.13-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 1.3.13-5 🚀
|
Details
This PR fixes the condition which set the value of terms of service checkbox inside the draft state.
Fixed Issues
$ #16885
PROPOSAL: #16885 (comment)
Tests
Verify that the checkbox remains unchecked.
Offline tests
N/A
QA Steps
Verify that the checkbox remains unchecked.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Screen.Recording.2023-05-05.at.6.56.33.PM.mov
Mobile Web - Chrome
Screen.Recording.2023-05-05.at.7.06.44.PM.mov
Mobile Web - Safari
Screen.Recording.2023-05-05.at.7.04.27.PM.mov
Desktop
Screen.Recording.2023-05-05.at.7.02.18.PM.mov
iOS
Screen.Recording.2023-05-05.at.7.19.04.PM.mov
Android
Screen.Recording.2023-05-05.at.7.17.30.PM.mov