[TS migration] Migrate 'SelectCircle.js' component to TypeScript#30077
[TS migration] Migrate 'SelectCircle.js' component to TypeScript#30077cead22 merged 9 commits intoExpensify:mainfrom
Conversation
| </View> | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
We should always define displayName:
| SelectCircle.displayName = 'SelectCircle'; |
| isChecked: boolean; | ||
|
|
||
| /** Additional styles to pass to SelectCircle */ | ||
| styles: Array<Record<string, unknown>>; |
There was a problem hiding this comment.
Please use more accurate type here, ViewStyle[]?
|
|
||
| function SelectCircle({isChecked = false, styles = []}: SelectCircleProps) { | ||
| return ( | ||
| <View style={[globalStyles.selectCircle, globalStyles.alignSelfCenter, styles]}> |
There was a problem hiding this comment.
Typescript made me get rid of the spread operator (...styles -> styles) after I switched from an Array<> to StyleProp<>. But the weird thing is that it still works when styles are passed like they used to be: <SelectCircle isChecked={props.isSelected} styles={[styles.singleOptionSelectorCircle]} />
There was a problem hiding this comment.
If it works, that's fine with me. Please test that the styles are displayed correctly.
There was a problem hiding this comment.
Yes, works just fine
There was a problem hiding this comment.
Should we check that styles isn't null?
There was a problem hiding this comment.
@cead22 Styles accept falsy values, so no need for such check:
type Falsy = undefined | null | false;
export type StyleProp<T> =
| T
| RegisteredStyle<T>
| RecursiveArray<T | RegisteredStyle<T> | Falsy>
| Falsy;
fabioh8010
left a comment
There was a problem hiding this comment.
@MaciejSWM I think we should update the PR title to [TS migration] Migrate 'SelectCircle.js' component to TypeScript, in order to QA team to test it.
Co-authored-by: Fábio Henriques <fabio.lacerda@outlook.com>
|
@cubuspl42 Please 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] |
Reviewer Checklist
Screenshots/VideosWebselect-circle-web.mp4Mobile Web - Chromeselect-circle-android-web-compressed.mp4Mobile Web - Safariselect-circle-ios-web.mp4DesktopiOSselect-circle-ios.mp4Androidselect-circle-android-compressed.mp4 |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #25015 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
| isChecked: boolean; | ||
|
|
||
| /** Additional styles to pass to SelectCircle */ | ||
| styles?: StyleProp<ViewStyle>; |
There was a problem hiding this comment.
Is there no way to define a default for this prop like []?
There was a problem hiding this comment.
It is possible, we can default it to []. cc @MaciejSWM
There was a problem hiding this comment.
Hey @cead22. Thanks for spotting this. It turns out that no action is needed, as RN+TS still work well when styles are undefined. Please see this:
https://github.com/Expensify/App/pull/29988/files#r1373207252
Especially the first example that passes no styles to FullScreenLoadingIndicator: https://github.com/Expensify/App/pull/29988/files#r1374544242
|
|
||
| function SelectCircle({isChecked = false, styles = []}: SelectCircleProps) { | ||
| return ( | ||
| <View style={[globalStyles.selectCircle, globalStyles.alignSelfCenter, styles]}> |
There was a problem hiding this comment.
Should we check that styles isn't null?
|
✋ 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/cead22 in version: 1.3.96-0 🚀
|
|
@MaciejSWM Could you please share the QA steps. We need help with the following steps in "Tests" section.
|
|
I updated the QA section @kavimuru. It will be enough just to test if the SelectCircle component works correctly in the app, no need to change the background color as it was just to highlight more easily that you're looking at the correct component. |
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.96-15 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.97-7 🚀
|
Details
Fixed Issues
$ #25015
PROPOSAL:
Tests
styles.tsfindselectCircleand change it's background color to something bright:backgroundColor: 'red',Start Chat, clickAdd to groupfor a couple of users. You should see the SelectCircle component working correctly, and having a red background:Offline tests
QA StepsQA Steps
Start Chat, clickAdd to groupfor a couple of users. You should see the SelectCircle component working correctly.PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.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
Android: Native
Screen.Recording.2023-10-20.at.15.32.18.mov
Android: mWeb Chrome
Screen.Recording.2023-10-20.at.15.33.28.mov
iOS: Native
Screen.Recording.2023-10-20.at.15.13.06.mov
iOS: mWeb Safari
Screen.Recording.2023-10-20.at.15.14.24.mov
MacOS: Chrome / Safari
Screen.Recording.2023-10-20.at.15.34.59.mov
MacOS: Desktop
Screen.Recording.2023-10-20.at.15.35.40.mov