Skip to content
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

[HOLD for payment 2023-07-10] [$1000] Web - 'Find a member' doesn't update dynamically on the placeholder #21061

Closed
1 of 6 tasks
kbecciv opened this issue Jun 19, 2023 · 34 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Jun 19, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

Action Performed:

  1. Go to staging dot on web chrome
  2. Go to any workspace
  3. Go to invite members and notice that when the search field is not focused, the 'Find a member' is shown on the placeholder
  4. But if you click on the search field, the 'Find a member' goes on top allowing users to input the text on the search field
  5. Now invite some members
  6. Now, search the member using the initials of one invited member
  7. Click on select all and now remove the user
  8. Next click on invite button on top and then click on go back to return to the list of users
  9. Notice that now, even when the search field is not focused , the 'Find a member' is shown at the top (In previous cases -step 3 and 4, 'Find a member' was shown on top only when the search field was focused). If you refresh the page you can notice that the 'Find a member' is updated in the placeholder of the search field now.

Expected Result:

'Find a member' should be update dynamically on the placeholder

Actual Result:

'Find a member' doesn't update dynamically on the placeholder

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.29.3

Reproducible in staging?: yes

Reproducible in production?: yrs

If this was caught during regression testing, add the test name, ID and link from TestRail:

Email or phone of affected tester (no customers):

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

error-2023-06-11_12.23.01.1.mp4
Recording.5028.mp4

Expensify/Expensify Issue URL:

Issue reported by: @priya-zha

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1686466494275769

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a2b58955cd2caa4f
  • Upwork Job ID: 1671383734343749632
  • Last Price Increase: 2023-06-21
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 19, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 19, 2023

Triggered auto assignment to @JmillsExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Jun 19, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@dukenv0307
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

'Find a member' doesn't update dynamically on the placeholder

What is the root cause of that problem?

When clicking invite button we will clear the text input and reset this.state.value in here

this.setState({value: inputValue, selection: this.props.selection});

And then deactivateLabel function is called if the inputValue is empty

if (inputValue) {
this.activateLabel();
} else if (!this.state.isFocused) {
this.deactivateLabel();
}

but Inside deactivateLabel itself we're checking if this.state.value.length !== 0 we will do nothing
if (this.props.forceActiveLabel || this.state.value.length !== 0 || this.props.prefixCharacter) {
.
It causes race condition where inputValue becomes empty but the state.value doesn't update to empty yet inside deactivateLabel, causing the label not to be deactivated

What changes do you think we should make in order to solve the problem?

We should move this code

if (inputValue) {
this.activateLabel();
} else if (!this.state.isFocused) {
this.deactivateLabel();
}

to the callback of setState function

this.setState({value: inputValue, selection: this.props.selection}, () => {
            if (inputValue) {
                this.activateLabel();
            } else if (!this.state.isFocused) {
                this.deactivateLabel();
            }
        });

What alternative solutions did you explore? (Optional)

We also pass new param to this.deactivateLabel(inputValue); function and using this params to check instead of this.state.value

deactivateLabel(inputValue =  this.state.value) {
        if (this.props.forceActiveLabel || inputValue.length !== 0 || this.props.prefixCharacter) {
            return;
        }
        this.animateLabel(styleConst.INACTIVE_LABEL_TRANSLATE_Y, styleConst.INACTIVE_LABEL_SCALE);
        this.isLabelActive = false;
    }

@bernhardoj
Copy link
Contributor

bernhardoj commented Jun 20, 2023

I have posted my proposal here #19231 (comment), so copying it here

Proposal

Please re-state the problem that we are trying to solve in this issue.

Text input label does not deactivate (move back as the placeholder) when we clear the input value (it will be cleared when going back from the invite page). To reproduce it, make sure to type something first.

What is the root cause of that problem?

Actually, we already have the code that SHOULD deactivate the label when we clear the input value here:

// Activate or deactivate the label when value is changed programmatically from outside
const inputValue = _.isUndefined(this.props.value) ? this.input.value : this.props.value;
if ((_.isUndefined(inputValue) || this.state.value === inputValue) && _.isEqual(prevProps.selection, this.props.selection)) {
return;
}
// eslint-disable-next-line react/no-did-update-set-state
this.setState({value: inputValue, selection: this.props.selection});
// In some cases, When the value prop is empty, it is not properly updated on the TextInput due to its uncontrolled nature, thus manually clearing the TextInput.
if (inputValue === '') {
this.input.clear();
}
if (inputValue) {
this.activateLabel();
} else if (!this.state.isFocused) {
this.deactivateLabel();
}

As you can see, we update the value state with inputValue and call deactivateLabel if inputValue is empty. Then, inside deactivateLabel, we check if the state of value is empty or not.

deactivateLabel() {
if (this.props.forceActiveLabel || this.state.value.length !== 0 || this.props.prefixCharacter) {
return;
}
this.animateLabel(styleConst.INACTIVE_LABEL_TRANSLATE_Y, styleConst.INACTIVE_LABEL_SCALE);
this.isLabelActive = false;
}

If it's empty, then we proceed to deactivate the label. The problem is, the value state is not updated yet inside deactivateLabel, which is basically a race condition.

What changes do you think we should make in order to solve the problem?

Call the deactivateLabel inside the setState callback.

More specifically, move this code to be inside the setState callback.

if (inputValue) {
this.activateLabel();
} else if (!this.state.isFocused) {
this.deactivateLabel();
}

I guess we also can change inputValue to this.state.value instead.

@JmillsExpensify
Copy link

While we expect to overhaul this entire flow soon, I'm going to go ahead and triage. I also wasn't able to reproduce on either Safari or desktop.

@JmillsExpensify JmillsExpensify added the External Added to denote the issue can be worked on by a contributor label Jun 21, 2023
@melvin-bot melvin-bot bot changed the title Web - 'Find a member' doesn't update dynamically on the placeholder [$1000] Web - 'Find a member' doesn't update dynamically on the placeholder Jun 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 21, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01a2b58955cd2caa4f

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 21, 2023

Current assignee @JmillsExpensify is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Jun 21, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane (External)

@teguhkurnia
Copy link

Proposal

Please re-state the problem that we are trying to solve in this issue.

'Find a member' doesn't update dynamically on the placeholder

What is the root cause of that problem?

The root of this problem is that the setState function doesn't update the state immediately, because the setState is Asynchronous

In your code, you called the deactivateLabel() function immediately after the setState function, but inside the deactivateLabel() function you have an if statement that has checked the this.state.value.length !== 0.

As I said before value state is not changed yet in this case. So if you check the value immediately after the setState is called the value is the same as before.

What changes do you think we should make in order to solve the problem?

setState function has a callback argument, that callback argument is called if the state has already changed, so we can call the deactivateLabel() function inside the callback argument.

What alternative solutions did you explore? (Optional)

Or, we can add an argument to the deactivateLabel() function that is the changed input value in your case is inputValue variable, sodeactivateLabel(inputValue).
and on the deactivateLabel() function we can check the input value not from the state, but from the argument

@melvin-bot
Copy link

melvin-bot bot commented Jun 26, 2023

📣 @teguhkurnia! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@teguhkurnia
Copy link

Contributor details
Your Expensify account email: vayim63018@byorby.com
Upwork Profile Link: https://www.upwork.com/freelancers/~016b08cfd1ddef1a1a

@melvin-bot
Copy link

melvin-bot bot commented Jun 26, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@sobitneupane
Copy link
Contributor

@melvin-bot melvin-bot bot removed the Overdue label Jun 26, 2023
@sobitneupane
Copy link
Contributor

This issue is almost same as this issue where @bernhardoj had proposed #19231 (comment) solution. It solves the issue. But for consistency we decided to change the requirement of that issue. So, considering this issue just the extension of #19231. We have decided to go with @bernhardoj's proposal.

🎀 👀 🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Jun 27, 2023

Triggered auto assignment to @johnmlee101, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@johnmlee101
Copy link
Contributor

Makes sense to me.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 27, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 27, 2023

📣 @bernhardoj You have been assigned to this job by @johnmlee101!
Please apply to this job in Upwork and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@bernhardoj
Copy link
Contributor

PR is ready.

cc: @sobitneupane

@melvin-bot
Copy link

melvin-bot bot commented Jun 28, 2023

🎯 ⚡️ Woah @sobitneupane / @bernhardoj, great job pushing this forwards! ⚡️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉

  • when @bernhardoj got assigned: 2023-06-27 19:22:12 Z
  • when the PR got merged: 2023-06-28 21:07:48 UTC

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jul 3, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Web - 'Find a member' doesn't update dynamically on the placeholder [HOLD for payment 2023-07-10] [$1000] Web - 'Find a member' doesn't update dynamically on the placeholder Jul 3, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 3, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot
Copy link

melvin-bot bot commented Jul 3, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.35-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-07-10. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Jul 3, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@sobitneupane] The PR that introduced the bug has been identified. Link to the PR:
  • [@sobitneupane] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@sobitneupane] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@sobitneupane] Determine if we should create a regression test for this bug.
  • [@sobitneupane] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@JmillsExpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 9, 2023
@sobitneupane
Copy link
Contributor

sobitneupane commented Jul 10, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@sobitneupane] The PR that introduced the bug has been identified. Link to the PR:

#9056

  • [@sobitneupane] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:

https://github.com/Expensify/App/pull/9056/files#r1257910704

  • [@sobitneupane] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:

https://expensify.slack.com/archives/C049HHMV9SM/p1688978277278329

  • [@sobitneupane] Determine if we should create a regression test for this bug.

yes.

  • [@sobitneupane] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

#21061 (comment)

@sobitneupane
Copy link
Contributor

Regression Test Proposal

  1. Go to Settings > Workspaces > Select any workspace > Members
  2. In the "Find a member" input, type something
  3. Verify the "Find a member" label moves up
  4. Press the Invite button
  5. Go back by pressing back button
  6. Verify the input is cleared and "Find a member" label moves back to its original position

Do we agree 👍 or 👎

@sobitneupane
Copy link
Contributor

Payment Requested on Expensify

@melvin-bot melvin-bot bot added the Overdue label Jul 12, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2023

@JmillsExpensify, @johnmlee101, @sobitneupane, @bernhardoj Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot
Copy link

melvin-bot bot commented Jul 17, 2023

@JmillsExpensify, @johnmlee101, @sobitneupane, @bernhardoj 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

@johnmlee101
Copy link
Contributor

Where are we with payment?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 24, 2023

@JmillsExpensify, @johnmlee101, @sobitneupane, @bernhardoj Huh... This is 4 days overdue. Who can take care of this?

@JmillsExpensify
Copy link

Circling back on this now.

@melvin-bot melvin-bot bot removed the Overdue label Jul 24, 2023
@JmillsExpensify
Copy link

@bernhardoj I sent you an offer via Upwork. I'll pay the bonus when closing out the contract. Thanks!

@bernhardoj
Copy link
Contributor

Accepted

@JmillsExpensify
Copy link

All paid out, including the bonus. Still need to create the issue for TestRail, so I'll do that before closing this one out.

@JmillsExpensify
Copy link

Test created. Closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

7 participants