[HOLD for payment 2021-11-12] LHN: Hide the pencil icon when message is sent or draft is deleted and show the icon when user started to type
If you havenโt already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
- Type a draft message in some chat.
- The pencil icon for draft does not show up.
- Switch to another chat to see the pencil icon appear and then move back to the chat with draft.
- Sent or delete the message.
Expected Result:
The pencil icon should not be visible when there is no draft in the report.
Let's separate the pencil icon behaviour from the LHN reordering. Show the pencil icon whenever users creates the draft (immediately) and hide the pencil icon as soon as the draft is either deleted or message sent (also immediately). However, keep the LHN reordering same, we do not want the LHN to reorder while typing as that is very distracting.
Actual Result:
Observe that the pencil icon is still visible in the LHN even though we have no draft at the moment.
Workaround:
User can switch to different report or reload and the pencil icon will disappear.
Platform:
Where is this issue occurring?
- Web
- Desktop App
Version Number: Reproducible in staging?: Reproducible in production?: Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation Expensify/Expensify Issue URL: Issue reported by: @AndrewGable Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1635195542084000
Triggered auto assignment to @SofiedeVreese (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
Posted on Upwork: https://www.upwork.com/jobs/~013ddffbd27504e496
@mountiny did you want to CME this one? Let me know if not, and I can remove you from the issue and assign a CME.
Proposal
SidebarLinks.js
- Rename
shouldComponentUpdatetoshouldReorder - Add:
constructor(props) {
super(props);
this.state = { shouldReorder: true };
}
componentWillReceiveProps(nextProps) {
this.state.shouldReorder = this.shouldReorder(nextProps)
}
- Pass it to the
getSidebarOptionscall inrender():
const {recentReports} = getSidebarOptions(
...
this.state.shouldReorder
);
OptionsListUtils.js
- Add a new param to
getSidebarOptions():
function getSidebarOptions(
...
prioritizeReportsWithDraftComments
)
- Replace the constant below with the param:
let sideBarOptions = {
...
prioritizeReportsWithDraftComments: prioritizeReportsWithDraftComments,
};
@SofiedeVreese I would like to keep this as I was CME on issue, which kind of introduced this problem and this is an improvement from it ๐ .
@marktoman Hi Mark! Thank you for your proposal, I am not sure if this proposal really solves the problem described in the issue body. Could you please elaborate a bit more and ideally include a screen recording of the behaviour being fixed/being as expected with those proposed changes? Thank you very much!
@mountiny Sure. Currently shouldComponentUpdate has logic to determine if the user is typing. If yes, then it returns false so it does not update and reorder.
I have separated the reorder behavior from the update by:
- Removing
shouldComponentUpdate. Doing so makes the pencil icon appear and disappear properly. - Binding the logic previously in
shouldComponentUpdateto the parameter determining if the list will reorder at any given moment.
https://user-images.githubusercontent.com/47689923/138879381-9f6d0eb6-9d48-40e6-9f4b-beae306d610f.mp4
@marktoman Thank you for the clarification. Sorry if this was not clear form the issue description, but could we look into making the pencil icon show up/hide immediately when some text is added/removed? There is a delay now, I am not sure if that requires some more substantial changes.
Thank you very much for looking into this one!
Done. I will post a complete solution soon.
https://user-images.githubusercontent.com/47689923/138923716-77778b1c-a72f-4fd5-ba99-a661fd40fd46.mp4
Not sure if it's helpful but... the reproduction steps that I found while testing are
- start drafting a message to a user - no pencil icon shows (as expected)
Command+k toopen search/chat switcher start typing a user name then clickesckey to return to the chat you started typing draft in- Observe pencil icon in Left Hand Nav (LHN) (NOT expected behavior)
- Send message
- Obverse pencil icon still shows in LHN when there is no text in compose box (NOT expected behavior)
Regardless... I only think the pencil icon should be shown when there is a background chat that contains text in the compose box or an uncompleted action (which I can't think of what any of those might be since uploading an attachment is it's own modal and requesting money pops out RHN)
@mallenexpensify Alright, this is about what we want the behaviour to look like in the end. I remember we were discussing it before, we can update the expected behaviour, however, it would most likely complicate the solution.
I think that for now, the pencil icon appearing right when you start to type is not as distracting since it is a moment you hit the keyboard. I think we should first change it to show the icon immediately when there is some text.
If we would then find this not ideal either, we could create new issue to improve it, but I would not add it to scope of this issue.
The solution brings two changes:
- Previously, determining whether the user has a draft comment was based on the actual stored text. The problem is that the draft save is debounced in order to limit re-renders. I have added a new boolean key to indicate if a given report has a draft, which does not need to be debounced.
- Preventing re-order was done by freezing the list update, which prevented refreshing the icon. Instead, we are now conditionally ordering the items independent of the list update.
@marktoman Thank you for working on that proposal. I will have a look over it properly but so far I like it. Could you please apply for the job on Upwork and post here once you have done so?
Since we would make a few changes in this, we need to make sure this gets tested really well for any regressions.
@SofiedeVreese Could you please hire @marktoman on Upwork, once they apply? Thank you very much ๐
Also I noticed now this will be your first PR in this App! Great to have you onboard and I hope we can get this change to successful end ๐
For future reference, avoid creating a PR before you are hired or assigned to the job and just write the proposal out in here, with video/image as prove it works. Once an assigned engineer will approve, feel free to start the PR:)
@mountiny @SofiedeVreese Applied. Thank you, glad you like it!
Hi @marktoman I've just hired you in Upwork!
@marktoman Congratulations! Just as a reminder of our contributor guidelines, as a first time contributor, you can only work on one issue at a time. Once we finish this one, you can send proposals to many issues and potentially work on them in parallel.
PR is in a review!
Close to being deployed.
@marktoman @SofiedeVreese There has been a regression detected which has been introduced in PR solving this issue. We need to resolve that. Link is slack: https://expensify.slack.com/archives/C01GTK53T8Q/p1636082766011900
BUG: Blank screen after logout

Looks like the regression's been fixed. I'm going to add a "hold for payment", 7 days from the original deploy.