migrate CopyTextToClipboard to functional component#20107
Conversation
|
@PauloGasparSv @mollfpr 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] |
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
Re-opening this, I think it was closed by mistake : ) |
|
@PauloGasparSv Tried to close+open to see if the check will go through :D |
|
@nhminhduc Could you resolve the lint issues? Thanks! |
mollfpr
left a comment
There was a problem hiding this comment.
Need to resolve the lint issue and other style problem. @nhminhduc If you using vscode, you can try the command "Format Document With..." > "Prettier - Code formatter".
| import withLocalize, {withLocalizePropTypes} from './withLocalize'; | ||
| import withDelayToggleButtonState, {withDelayToggleButtonStatePropTypes} from './withDelayToggleButtonState'; | ||
| import withLocalize, { withLocalizePropTypes } from './withLocalize'; | ||
| import withDelayToggleButtonState, { withDelayToggleButtonStatePropTypes } from './withDelayToggleButtonState'; |
There was a problem hiding this comment.
@nhminhduc I think we don't add spaces between brackets.
| import withDelayToggleButtonState, { withDelayToggleButtonStatePropTypes } from './withDelayToggleButtonState'; | |
| import withDelayToggleButtonState, {withDelayToggleButtonStatePropTypes} from './withDelayToggleButtonState'; |
| <Text style={textStyles}>{`${text} `}</Text> | ||
| <Tooltip text={translate(`reportActionContextMenu.${isDelayButtonStateComplete ? 'copied' : 'copyToClipboard'}`)}> | ||
| <Pressable onPress={copyToClipboard}> | ||
| {({ hovered, pressed }) => ( |
There was a problem hiding this comment.
No spaces before/after bracket.
| {({ hovered, pressed }) => ( | |
| {({hovered, pressed}) => ( |
|
|
||
| /** Styles to apply to the text */ | ||
| // eslint-disable-next-line react/forbid-prop-types | ||
| textStyles: PropTypes.arrayOf(PropTypes.object), |
There was a problem hiding this comment.
@nhminhduc Any reason to remove the lint disable?
There was a problem hiding this comment.
Not really, it doesn't alert on my pc. But I added it again just in case.
|
|
||
| copyToClipboard() { | ||
| if (this.props.isDelayButtonStateComplete) { | ||
| const CopyTextToClipboard = ({ text, textStyles, translate, isDelayButtonStateComplete, toggleDelayButtonState }) => { |
There was a problem hiding this comment.
Don't destructure props or state. It makes the source of a given variable unclear. This guideline helps us quickly know which variables are from props, state, or from some other scope.
@nhminhduc Could you update these destruct props?
There was a problem hiding this comment.
Fixed, using props instead.
Reviewer Checklist
Screenshots/VideosWeb20107.Web.movMobile Web - Chrome20107.mWeb.Chrome.movMobile Web - Safari20107.mWeb.Safari.mp4Desktop20107.Desktop.moviOS20107.iOS.mp4Android20107.Android.mov |
|
Updated to keep up with main branch: |
|
@nhminhduc Could you resolve the lint issue? |
| Clipboard.setString(this.props.text); | ||
| const CopyTextToClipboard = (props) => { | ||
| const copyToClipboard = () => { | ||
| Clipboard.setString(props.text); |
There was a problem hiding this comment.
@nhminhduc @PauloGasparSv Do you guys agree if we wrap this with useCallback since it has dependencies of props.text?
…ate-CopyTextToClipboard
|
Added useCallback, displayName and fixed lint. |
Thank you for your time 🙇 |
|
Hi @nhminhduc, can you please fix the linter errors here? (I think running Will review here anyways and re-approve once that's done : ) |
|
Tested all platforms and LGTM! I'm double checking Android before approving because the copy icon isn't there, I'm curious if that was also happening on |
PauloGasparSv
left a comment
There was a problem hiding this comment.
LGTM!
Tested main and the copy icon doesn't show in the Contact Methods page there either.
Waiting on the linter fix to merge this
|
Run prettier 👍 |
|
I think on android the icon is showing, just the color is quite off. Not sure why. |
@nhminhduc do you mind updating the QA steps to use the Copy icon from somewhere else then? I think this will be reported as a problem if we don't explain in the QA section : ) |
I will update it tomorrow. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
@PauloGasparSv @mollfpr Hi, the icon in Android is indeed missing and it is a bug. But I do not think it is from this PR. |
I think that would be awesome @nhminhduc! So that's why, thks so much for explaining it too! |
|
🚀 Deployed to staging by https://github.com/PauloGasparSv in version: 1.3.26-0 🚀
|
|
This PR QA is blocked on Android because of this issue #17368. Rest of the platforms is a pass. |
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 1.3.26-4 🚀
|




Details
Fixed Issues
$ #16132
PROPOSAL: #16132 (comment)
Tests
Offline tests
Same as online
QA Steps
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
Web
web.mp4
Mobile Web - Chrome
chrome.mp4
Mobile Web - Safari
safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov