Repository navigation
Edit Comments - #2320
Edit Comments#2320
Conversation
| style={[styles.textInput, styles.flex0]} | ||
| /> | ||
| <View style={[styles.flexRow, styles.mt1]}> | ||
| <TouchableOpacity style={[styles.button, styles.mr2]}> |
There was a problem hiding this comment.
As stated in this thread, I would prefer to see something like this:
<Pressable
onPress={this.deleteDraft}
style={({hovered, pressed}) => [
styles.button,
styles.mr2,
getButtonBackgroundColorStyle(getButtonState(hovered, pressed)),
]}
/>There was a problem hiding this comment.
Also, I see you switched to Pressable but didn't use the style callback w/ getButtonBackgroundColorStyle(getButtonState(hovered, pressed))
There was a problem hiding this comment.
We might need @Expensify/design's help to think around 2 things:
- The normal button hover color is the same as the hover color for the comment:
- There is a
greenHovercolor, however, what should we use forgreenPressed?

Or perhaps better yet, do we need button styles for hover for the edit comment buttons?
| Cancel | ||
| </Text> | ||
| </TouchableOpacity> | ||
| <TouchableOpacity style={[styles.button, styles.buttonSuccess]}> |
There was a problem hiding this comment.
Same here, but you would just have to create something like getButtonSuccessBackgroundColorStyle
<Pressable
onPress={this.deleteDraft}
style={({hovered, pressed}) => [
styles.button,
styles.mr2,
getButtonSuccessBackgroundColorStyle(getButtonState(hovered, pressed)),
]}
/>| </Text> | ||
| </TouchableOpacity> | ||
| <TouchableOpacity style={[styles.button, styles.buttonSuccess]}> | ||
| <Text style={[styles.buttonText, styles.buttonSuccessText]} onPress={this.publishDraft}> |
There was a problem hiding this comment.
Same here with the onPress given to the Text
| fetchAll(false); | ||
| }); | ||
|
|
||
| function editReportComment(reportID, reportAction, htmlForNewComment) { |
There was a problem hiding this comment.
Missing a method doc here
|
|
||
| function editReportComment(reportID, reportAction, htmlForNewComment) { | ||
| // Optimistically update the report action with the new message | ||
| const sequenceNumber = reportAction.sequenceNumber; |
There was a problem hiding this comment.
I was just reviewing @sketchydroide's delete comment PR, and I thought the way he approached this syntactically was a bit cleaner (and has better error handling):
function editReportComment(reportID, reportAction, htmlForNewComment) {
// Optimistically update Onyx
actionToMerge = {}'
const oldMessage = {...reportAction.message};
actionToMerge[reportAction.sequenceNumber] = {
...reportAction,
message: [
{
type: 'COMMENT',
html: htmlForNewComment,
text: htmlForNewComment.replace(/<[^>]*>?/gm, ''),
},
],
};
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, actionToMerge);
// Make the API request
API.Report_EditComment({
reportID,
reportActionID: reportAction.reportActionID,
reportComment: htmlForNewComment,
})
.catch(() => {
// If it fails, reset Onyx
actionToMerge[reportAction.sequenceNumber] = {
...reportAction,
message: oldMessage,
};
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, reportActionsToMerge);
});
}There was a problem hiding this comment.
I like the error handling, but I actually find my way to be less confusing. Maybe that's just because I wrote it so I'm familiar with it, but it's a little more clear what's exactly is being edited.
268af75 to
2594d4f
Compare
|
HEYO! I am removing this WIP! Please take a look! 🙇 |
|
🚀 Deployed to staging in version: 1.0.41-7🚀
|
Blue screen displayed when trying to edit message.Expected ResultA context menu should show up Actual ResultScreen becomes blue after long tap on message Action Performed
PlatformiOS ✔️ Notes/images/Video Bug5063742_RPReplay_Final1620758969.mp4 |
|
@isagoico This could happen before this PR, can you create a separate issue? |
|
Tester was unable to reproduce the same blue screen in prod but it seems really similar to this issue #2705. Should I include the new info there? or just create a separate issue? |
|
Okay, yeah good idea to just add it in there |
|
Perfect, will remove the deploy blocker label then |
|
🚀 Deployed to production in version: 1.0.44-0🚀
|
|
I am tagging this PR to highlight an issue fixed here. All conditions in ternary expressions or left-hand operands on conditional renders, should be boolean. This PR is one of the PRs that uses conditional render with string operands, hence I am tagging it here for the contributors to check. We've also updated the item in the checklist with this PR to avoid this issue in the future. |
| */ | ||
| deleteDraft() { | ||
| saveReportActionDraft(this.props.reportID, this.props.action.reportActionID, ''); | ||
| toggleReportActionComposeView(true, this.props.isSmallScreenWidth); |
There was a problem hiding this comment.
This caused a regression (case 2). If we delete any comment the main composer will show up, even if we are deleting a non-focused message.
What we had to do is to add a condition where we show the main composer only if we are deleting the currently focused message.
| super(props); | ||
| this.updateDraft = this.updateDraft.bind(this); | ||
| this.deleteDraft = this.deleteDraft.bind(this); | ||
| this.debouncedSaveDraft = _.debounce(this.debouncedSaveDraft.bind(this), 1000, true); |
There was a problem hiding this comment.
Coming from #38483.
We can clear the side effects like this debounce when the component unmounts.
No one could have imagined that there would be multiple instances of this component at the same time. 😂
| style={[styles.textInput, styles.flex0]} | ||
| onFocus={() => { | ||
| scrollToIndex({animated: true, index: this.props.index}, true); | ||
| toggleReportActionComposeView(false); |
There was a problem hiding this comment.
Since scrolling and toggling of the composer could result in a race condition due to animations, it is better to wait for the animations to complete before scrolling. This caused an issue #40767 where the composer box is partially hidden.
Pullerbearing (@MariaHCD)
cc @roryabraham
Details
Give users the ability to edit their comments!
Fixed Issues
Fixes https://github.com/Expensify/Expensify/issues/147482
Fixes https://github.com/Expensify/Expensify/issues/162717
Tests/QA
(edited)showing up next to the comment nowTested On
Screenshots
Web
Mobile Web
Desktop
iOS
Android
I can't get the Android emulator to run without slowing my machine to a crawl so animations, so here are some stills:


