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-08-16] [$1000] Web - Task - Error is shown as soon as app is put in background when creating a task #23552

Closed
1 of 6 tasks
kbecciv opened this issue Jul 25, 2023 · 37 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 Jul 25, 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:

  1. Open the testing app
  2. Open any chat
  3. Click on the + icon and select Assign task
  4. Put the desktop app in background (navigate to another another open app or desktop)
  5. Put the app back in foreground

Expected Result:

No error message in the title field to appear since user have not clicked on next/continue button yet

Actual Result:

Error message appear in the task title field once app is brought back to foreground

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.45-1
Reproducible in staging?: y
Reproducible in production?: y
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

Bug6140912_Screen_Recording_2023-07-25_at_1.45.31_PM.mp4

Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~014f687ec29289cd8a
  • Upwork Job ID: 1684312907864506368
  • 2023-07-26
  • Automatic offers:
    • tienifr | Contributor | 25860865
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 25, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 25, 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

@dummy-1111
Copy link
Contributor

Not sure if this is an expected behavior.
Anyway posting a proposal

@dummy-1111
Copy link
Contributor

Proposal

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

Assign task - Error is shown on blur

What is the root cause of that problem?

We validate the fields by default as you can see below

App/src/components/Form.js

Lines 301 to 304 in 4af18f6

setTimeout(() => {
setTouchedInput(inputID);
onValidate(inputValues);
}, 200);

This is the root cause

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

I suggest to add the props called validateOnBlur to the form with default = true. If this value is set to false, we don't validate the form.

What alternative solutions did you explore? (Optional)

@alphaboss1104
Copy link
Contributor

alphaboss1104 commented Jul 25, 2023

Proposal

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

Error is shown as soon as app is put in background when creating a task.

What is the root cause of that problem?

App/src/components/Form.js

Lines 300 to 317 in 1205a74

onBlur: (event) => {
// We delay the validation in order to prevent Checkbox loss of focus when
// the user are focusing a TextInput and proceeds to toggle a CheckBox in
// web and mobile web platforms.
setTimeout(() => {
setTouchedInput(inputID);
// To prevent server errors from being cleared inadvertently, we only run validation on blur if any form values have changed since the last validation/submit
const shouldValidate = !_.isEqual(inputValues, lastValidatedValues.current);
if (shouldValidate) {
onValidate(inputValues);
}
}, 200);
if (_.isFunction(child.props.onBlur)) {
child.props.onBlur(event);
}
},

In the above code, the onBlur event is triggered when an input field loses focus. In other words, it’s executed when a user moves away from an input field.

When the app goes from the background to the foreground the onBlur event is triggered and onValidate(inputValues) function is invoked.

This is the root cause of this problem.

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

One approach to do this is to introduce a state that tracks whether the form has been submitted or not. Validation will only run when the form has been submitted.

Here’s how we could modify the NewTaskDetailsPage.js:

function NewTaskPage(props) {
    const inputRef = useRef();
    const [taskTitle, setTaskTitle] = useState(props.task.title);
    const [taskDescription, setTaskDescription] = useState(props.task.description || '');
+   const [isSubmitted, setIsSubmitted] = useState(false); // Add this line to track form submission

    useEffect(() => {
        setTaskTitle(props.task.title);
        setTaskDescription(props.task.description || '');
    }, [props.task]);

    function validate(values) {
        const errors = {};

+       if (!values.taskTitle && isSubmitted) { // Add isSubmitted condition here
            ErrorUtils.addErrorMessage(errors, 'taskTitle', 'newTaskPage.pleaseEnterTaskName');
        }

        return errors;
    }

    function onSubmit(values) {
+       setIsSubmitted(true); // Set isSubmitted to true when form is submitted
        Task.setDetailsValue(values.taskTitle, values.taskDescription);
        Navigation.navigate(ROUTES.NEW_TASK);
    }

    // ... rest of your code
}

What alternative solutions did you explore? (Optional)

None

@NicMendonca
Copy link
Contributor

@thienlnam is this expected behaviour?

@thienlnam
Copy link
Contributor

Not really a big problem, but I guess worth fixing

@NicMendonca NicMendonca added the External Added to denote the issue can be worked on by a contributor label Jul 26, 2023
@melvin-bot melvin-bot bot changed the title Web - Task - Error is shown as soon as app is put in background when creating a task [$1000] Web - Task - Error is shown as soon as app is put in background when creating a task Jul 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 26, 2023

Job added to Upwork: https://www.upwork.com/jobs/~014f687ec29289cd8a

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

melvin-bot bot commented Jul 26, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 26, 2023

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

@tienifr
Copy link
Contributor

tienifr commented Jul 27, 2023

Proposal

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

Error message appear in the task title field once app is brought back to foreground

What is the root cause of that problem?

That's because when the input in the form is blurred, in here

onBlur: (event) => {
, we're validating the form.

When the app is put in background, it also blurs the input and trigger the validation, causing a janky experience.

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

We need to trigger the validation onBlur only if the current app is visible and has focus (means the user proactively blurs the input while on the app), this will make the transition smooth when the user switches the app.

We can wrap the setTimeout here with the below:

if (Visibility.isVisible() && Visibility.hasFocus()) {
   ...
}

This is the same approach we're using to decide whether to show notification to the user in here

What alternative solutions did you explore? (Optional)

NA

@melvin-bot melvin-bot bot added the Overdue label Jul 28, 2023
@NicMendonca
Copy link
Contributor

@eVoloshchak bump on reviewing this ^^ proposal

@melvin-bot melvin-bot bot removed the Overdue label Jul 30, 2023
@eVoloshchak
Copy link
Contributor

@s-alves10 and @alphaboss1104's propose to validate the form on submit only, but I think we should retain the current behavior (and that would also mean the form behaves differently on different pages, which isn't ideal)

@tienifr,'s proposal looks good to me, that is the correct approach I think

We need to trigger the validation onBlur only if the current app is visible and has focus (means the user proactively blurs the input while on the app)

🎀👀🎀 C+ reviewed!

@melvin-bot
Copy link

melvin-bot bot commented Jul 31, 2023

Current assignee @thienlnam is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@thienlnam
Copy link
Contributor

@eVoloshchak Could you please remember to link the appropriate proposals in the reviewed message? Thank you in advance!

Agree with your analysis

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

melvin-bot bot commented Jul 31, 2023

📣 @eVoloshchak Please request via NewDot manual requests for the Reviewer role ($1000)

@melvin-bot
Copy link

melvin-bot bot commented Jul 31, 2023

📣 @tienifr 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer 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 📖

@parasharrajat
Copy link
Member

parasharrajat commented Aug 8, 2023

On a side note: I don't consider the applied solution a perfect solution for the following reasons:

  • We added a condition to prevent the main login on Mobile Chrome, creating a difference among platforms.
  • The visibility/focus logic is applied to all text inputs in the app. But the solution is only applied to Forms. What about the other pages where direct inputs are used and validation is applied on blur?

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 9, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Web - Task - Error is shown as soon as app is put in background when creating a task [HOLD for payment 2023-08-16] [$1000] Web - Task - Error is shown as soon as app is put in background when creating a task Aug 9, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 9, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 9, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.51-2 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-08-16. 🎊

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

For reference, here are some details about the assignees on this issue:

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 Aug 9, 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:

  • [@eVoloshchak] The PR that introduced the bug has been identified. Link to the PR:
  • [@eVoloshchak] 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:
  • [@eVoloshchak] 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:
  • [@eVoloshchak] Determine if we should create a regression test for this bug.
  • [@eVoloshchak] 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.
  • [@NicMendonca] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added the Overdue label Aug 21, 2023
@NicMendonca NicMendonca added Daily KSv2 and removed Weekly KSv2 labels Aug 21, 2023
@melvin-bot melvin-bot bot removed the Overdue label Aug 21, 2023
@NicMendonca
Copy link
Contributor

I'm so sorry for the delay in payment here. I don't know why this didn't change to daily for me 😓

@NicMendonca
Copy link
Contributor

@tienifr you've been paid

@NicMendonca
Copy link
Contributor

@eVoloshchak please don't forget to request payment via Expensify and fill out the BZ check list

@NicMendonca
Copy link
Contributor

@eVoloshchak
Copy link
Contributor

The visibility/focus logic is applied to all text inputs in the app. But the solution is only applied to Forms. What about the other pages where direct inputs are used and validation is applied on blur?

@parasharrajat, ultimately we only have two options

  • implement this logic on all those pages where direct inputs are used
  • refactor all of those pages to use Form

However, I could only find one occurrence of this (validation is applied on blur) in PDFPasswordForm (looks like it could be refactored to just use Form)

@eVoloshchak
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: this is the original implementation from [No QA] Create Form and FormActions #6412, I wouldn't call it a regression
  • 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: N/A
  • 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: I don't think an additional discussion is needed here

@eVoloshchak
Copy link
Contributor

Regression Test Proposal

  1. Navigate to any chat
  2. Click on the + icon and select Assign task
  3. Put the app in background (navigate to another open app or desktop, open another tab if on web)
  4. Put the app back in foreground/go back to the original tab
  5. Verify there is no error message in the title field

Do we agree 👍 or 👎

@parasharrajat
Copy link
Member

@eVoloshchak I don't know if we should further pursue this problem.

@thienlnam Do you think we should fix this #23552 (comment)? Technically, it is part of the problem.

@thienlnam
Copy link
Contributor

Sure, let's address that as well

My preference is just that we update those locations to use the Form component

@JmillsExpensify
Copy link

Reviewed the details for @eVoloshchak. $1,000 approved for payment via NewDot based on BZ summary.

@melvin-bot melvin-bot bot added the Overdue label Aug 25, 2023
@NicMendonca
Copy link
Contributor

@eVoloshchak thank you!

@melvin-bot melvin-bot bot removed the Overdue label Aug 25, 2023
@NicMendonca
Copy link
Contributor

all set here!

@parasharrajat
Copy link
Member

@NicMendonca There are pending changes here. ref: #23552 (comment) #23552 (comment)

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

9 participants