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 on PR 32432] [$500] Task - task title displays and removes error in few seconds on enter #33187

Closed
2 of 6 tasks
izarutskaya opened this issue Dec 15, 2023 · 14 comments
Closed
2 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@izarutskaya
Copy link

izarutskaya commented Dec 15, 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!


Version Number: v1.4.13-5
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
Expensify/Expensify Issue URL:
Issue reported by:
Slack conversation: @

Action Performed:

  1. Open the app
  2. Open any incomplete task report
  3. Click on title to edit it
  4. Remove the text and add space
  5. Click enter and observe that app displays 'Please enter a title' error for sometime and then removes the error

Expected Result:

App should display 'Please enter a title' error all the time after enter click when only space is present in task title field like it does on save click

Actual Result:

App displays 'Please enter a title' error for sometime and removes the error on click of enter when only space is present in title

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6314753_1702652808683.mac_desktop_-_task_title_space_enter_issue.mov
Bug6314753_1702652808661.mac_chrome_-_task_tile_space_enter_issue.mov
Bug6314753_1702652808668.windows_chrome_-_task_title_space_enter_issue.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~010c362ca46aa96208
  • Upwork Job ID: 1735734569855303680
  • Last Price Increase: 2023-12-15
@izarutskaya izarutskaya added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 15, 2023
@melvin-bot melvin-bot bot changed the title Task - task title displays and removes error in few seconds on enter [$500] Task - task title displays and removes error in few seconds on enter Dec 15, 2023
Copy link

melvin-bot bot commented Dec 15, 2023

Job added to Upwork: https://www.upwork.com/jobs/~010c362ca46aa96208

Copy link

melvin-bot bot commented Dec 15, 2023

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

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

melvin-bot bot commented Dec 15, 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

Copy link

melvin-bot bot commented Dec 15, 2023

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

@samilabud
Copy link
Contributor

samilabud commented Dec 15, 2023

Proposal

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

Task - task title displays and removes error in few seconds on enter

What is the root cause of that problem?

When we are using BaseTextInput (https://github.com/Expensify/App/blob/main/src/components/TextInput/BaseTextInput/index.js) the validation for input is only enabled when input gets blurred.

This is caused because in FormProvider component we do not define the input as a valid touched input and at the first time we validate this doesn't exist and error is not displayed:

const touchedInputErrors = _.pick(validateErrors, (inputValue, inputID) => Boolean(touchedInputs.current[inputID]));

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

When we edit we validate the inputs when we touch them, marking each one as touched using touchedInputs reference, we should mark the input when we are typing in:

onInputChange: (value, key) => {

The change should be like:

onInputChange: (value, key) => {
                        const inputKey = key || inputID;
                        setInputValues((prevState) => {
                            const newState = {
                                ...prevState,
                                [inputKey]: value,
                            };

                            if (shouldValidateOnChange) {
                                onValidate(newState);
                            }
                            return newState;
                        });
                        touchedInputs.current[inputID] = true;

                        if (propsToParse.shouldSaveDraft) {
                            FormActions.setDraftValues(formID, {[inputKey]: value});
                        }

                        if (_.isFunction(propsToParse.onValueChange)) {
                            propsToParse.onValueChange(value, inputKey);
                        }
                    },

Tests:
Before changes:

Before.changes.validate.input.when.task.edit.mp4

After changes:

After.changes.validate.input.when.task.edit.mp4

Copy link

melvin-bot bot commented Dec 15, 2023

📣 @m2jobe! 📣
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. Make sure you've read and understood the contributing guidelines.
  2. 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.
  3. 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.
  4. 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>

@Tony-MK
Copy link
Contributor

Tony-MK commented Dec 16, 2023

Proposal

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

Task title displays and removes error in few seconds on enter

What is the root cause of that problem?

The root cause of the problem is that when the form is initially rendered, we assume that the field is empty or the user will click on another element (shouldSetTouchedOnBlurOnly) to validate it. Hence, we don't call the setTouchedInput function in the FormProvider component in the initial render, although the user has already focused and is typing on the input element. Only when a click event is produced on the TaskTitlePage, is when is the title input stored in touchedInputs to be validate.

const touchedInputErrors = _.pick(validateErrors, (inputValue, inputID) => Boolean(touchedInputs.current[inputID]));
if (!_.isEqual(errors, touchedInputErrors)) {
setErrors(touchedInputErrors);
}

However, in this situation, the user can submit after typing the new empty title without causing the setTouchedInput to be called. Therefore, while the user is typing a new title, the form validator finds the error stored in validateErrors. Unfortunately, once it is picked by checking Boolean(touchedInputs.current[inputID]), the touchedInputErrors is {} because the inputID is not found in touchedInputs.

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

  1. Create an optional prop defaulted to {} for the FormProvider.js component. For this example, let's call it intialTouchedInput.

  2. Then, set it as the argument for useRef when initializing touchedInputs.

  3. Finally, set intialTouchedInput to {{"title": true}} and pass it to the FormProvider component, when creating TaskTitlePage.

Code Sample

// In TaskTitlePage.js
<FormProvider
...
enabledWhenOffline
intialTouchedInput={{"title": true}}
/>

// In FormProvider.js
...
const inputRefs = useRef({});
const touchedInputs = useRef(intialTouchedInput);
...

Note: It is possible to change intialTouchedInput to string and let it solely represent the inputID. However, it may require a conditional statement when initializing touchedInputs.

@shubham1206agra
Copy link
Contributor

@garrettmknight This is fixed by #32432

@melvin-bot melvin-bot bot added the Overdue label Dec 18, 2023
@rushatgabhane
Copy link
Member

rushatgabhane commented Dec 18, 2023

Agree with @shubham1206agra #33187 (comment)

@garrettmknight looks like we can close this issue after #32432 is deployed to staging, and we re-test this issue.

@melvin-bot melvin-bot bot removed the Overdue label Dec 18, 2023
@garrettmknight
Copy link
Contributor

Love to see it!

@garrettmknight garrettmknight changed the title [$500] Task - task title displays and removes error in few seconds on enter [HOLD on PR 32432] [$500] Task - task title displays and removes error in few seconds on enter Dec 18, 2023
@Tony-MK

This comment was marked as off-topic.

@shubham1206agra
Copy link
Contributor

Nope. Still not reproducible on staging

@melvin-bot melvin-bot bot added the Overdue label Dec 20, 2023
@Tony-MK
Copy link
Contributor

Tony-MK commented Dec 20, 2023

@shubham1206agra is correct. It's not reproducible on staging.

@garrettmknight
Copy link
Contributor

Looks like we're good here. Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

6 participants