Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.49k stars 2.85k forks source link

[HOLD for payment 2024-10-29] [HOLD for payment 2024-10-25] [$250] Android - Search - Keyboard does not auto open in Search modal #51010

Open IuliiaHerets opened 5 days ago

IuliiaHerets commented 5 days ago

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: 9.0.50-0 Reproducible in staging?: Y Reproducible in production?: N/A - new feature, doesn't exist in prod Email or phone of affected tester (no customers): applausetester+kh081006@applause.expensifail.com Issue reported by: Applause Internal Team

Action Performed:

  1. Launch New Expensify app.
  2. Open a report.
  3. Tap Search icon.

Expected Result:

Keyboard will auto open.

Actual Result:

Keyboard does not auto open.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/01e1dcce-315f-496d-9d31-2b69b83b354b

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021846960678624915682
  • Upwork Job ID: 1846960678624915682
  • Last Price Increase: 2024-10-17
  • Automatic offers:
    • abzokhattab | Contributor | 104471055
Issue OwnerCurrent Issue Owner: @sakluger
melvin-bot[bot] commented 5 days ago

Triggered auto assignment to @srikarparsi (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

melvin-bot[bot] commented 5 days ago

Triggered auto assignment to @sakluger (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

melvin-bot[bot] commented 5 days ago

💬 A slack conversation has been started in #expensify-open-source

github-actions[bot] commented 5 days ago

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.
abzokhattab commented 5 days ago

Edited by proposal-police: This proposal was edited at 2024-10-17 18:17:16 UTC.

Proposal

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

Search - Keyboard does not auto open in Search modal

What is the root cause of that problem?

keyboard doesnt open up because we dont use the useAutoFocusInput inside the SearchRouterInput component like we do in other textInput fields and the autoFocus doesn't work well on android with modals

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

we should assign the ref to the inputCallbackRef value of the useAutoFocusInput hook:

    const {inputCallbackRef } = useAutoFocusInput();

then use it in the TextInput here:

                        ref={inputCallbackRef}

then we could remove the autoFocus as its now handled by the useAutoFocusInput

What alternative solutions did you explore? (Optional)

optionally we can delay the focus so that the input field focuses correctly by adding shouldDelayFocus

rayane-djouah commented 5 days ago

cc @289Adam289 @Kicu @SzymczakJ @luacmartins

Kicu commented 5 days ago

Was this tested on a physical phone? Cos I'm testing this on android emulator right now (Pixel) and the keyboard does open:

https://github.com/user-attachments/assets/03b9bf9f-7cee-4dda-9ade-0f47feebc592

https://github.com/user-attachments/assets/8cb2c6b5-2ce6-4ff7-be97-44cab7d15de0

I did however noticed exactly one case where it didn't open, but I cannot reproduce it consistently. All the other cases it did open. I can test on a physical device later, but I'm curious if other people can reproduce this easily?

luacmartins commented 5 days ago

I can reliably reproduce this on a Pixel 6 physical device

srikarparsi commented 5 days ago

I'm also able to pretty reliably reproduce this on an emulator (I'm using Pixel 7 Pro API 33):

https://github.com/user-attachments/assets/78ab4279-40fa-4600-8f3f-6b55cf73b126

rayane-djouah commented 5 days ago

@Kicu I'm able to reproduce on android emulator

https://github.com/user-attachments/assets/19de4748-6838-49f7-86b4-ad223ad19d96

srikarparsi commented 5 days ago

Going to make this external

melvin-bot[bot] commented 5 days ago

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

melvin-bot[bot] commented 5 days ago

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

hayes102 commented 5 days ago

@rayane-djouah i am still not able to reproduce... is there a specific step that i am missing?

melvin-bot[bot] commented 5 days ago

📣 @hayes102! 📣 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>
huult commented 5 days ago

Proposal

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

Keyboard does not auto open in Search modal

What is the root cause of that problem?

This issue of react-native-modal

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

We should update follow this comment

//.src/components/Search/SearchRouter/SearchRouterInput.tsx#L87
+    useEffect(() => {
+        InteractionManager.runAfterInteractions(() => {
+            inputRef.current?.blur();
+            inputRef.current?.focus();
+        });
+    }, []);
https://github.com/user-attachments/assets/2f970dbe-037a-47ab-a7c0-afc28145c5ac
shahinyan11 commented 5 days ago

Edited by proposal-police: This proposal was edited at 2024-10-17 18:18:14 UTC.

Proposal

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

Android - Search - Keyboard does not auto open in Search modal

What is the root cause of that problem?

If the TextInput component is inside a some kind of view that renders asynchronously or after some delay, the keyboard may not open automatically. We already encounter such issues in other places . For example this one

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

  1. Add below code in SearchRouterInput component

    const inputRef = useRef<BaseTextInputRef | null>(null);
    
    useEffect(() => {
        if(autoFocus){
            InteractionManager.runAfterInteractions(()=>{
                inputRef.current?.focus();
            })
        }
    }, [])
  2. Add ref={inputRef} on TextInput component

    What alternative solutions did you explore? (Optional)

abzokhattab commented 5 days ago

Proposal updated

added an alternative proposal

huult commented 5 days ago

Note for C+: It looks like the other proposal also uses the shouldDelayFocus prop in TextInput to execute code similar to my example and changed after my proposal. https://github.com/Expensify/App/blob/0e388222c8425caa13cc0f88e1317edcc755ea0f/src/components/TextInput/BaseTextInput/index.tsx#L108-L121

jayeshmangwani commented 5 days ago

Both useAutoFocusInput and shouldDelayFocus work, but IMO we should go with useAutoFocusInput, as it's used across all auto-focused InputWrapper components.

@srikarparsi @luacmartins I'm attaching a video below to confirm how the input behaves after these changes. For example, if the keyboard is open on the report screen and we press 'Search' the following should happen:

  1. Keyboard will hide.
  2. Navigation to the Search screen will occur.
  3. Keyboard will reopen once navigation finishes.

https://github.com/user-attachments/assets/781091ac-014c-4e91-906c-768d0dadb727

huult commented 5 days ago

@jayeshmangwani , I tried using useAutoFocusInput during my debugging, but my emulator wasn’t working, so I didn't use it and found a new solution. Just a note for you. 😄

https://github.com/user-attachments/assets/271d6925-a448-4972-b372-c3d4cbe6a45d
jayeshmangwani commented 5 days ago

I tried using useAutoFocusInput during my debugging, but my emulator wasn’t working, so I didn't use it and found a new solution. Just a note for you. 😄

remove autoFocus and it will work 😄

srikarparsi commented 5 days ago

I'm attaching a video below to confirm how the input behaves after these changes. For example, if the keyboard is open on the report screen and we press 'Search' the following should happen:

Yes, this looks correct to me

srikarparsi commented 5 days ago

It looks like @abzokhattab’s proposal does this, @jayeshmangwani have you had a chance to verify this

jayeshmangwani commented 5 days ago

Yes, this looks correct to me

Great! We can go with @abzokhattab 's Proposal of using useAutoFocusInput

🎀 👀 🎀 C+ reviewed

melvin-bot[bot] commented 5 days ago

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

melvin-bot[bot] commented 5 days ago

📣 @abzokhattab 🎉 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 📖

srikarparsi commented 5 days ago

Awesome, @abzokhattab do you think you’ll be able to put up a PR soon?

abzokhattab commented 5 days ago

Thank you. the PR will be ready in the morning.

jayeshmangwani commented 5 days ago

have you had a chance to verify this

Yes I've tested, and it works fine

srikarparsi commented 5 days ago

Thank you. the PR will be ready in the morning.

Sorry, will that be in around an hour or a little longer. Since this is a deploy blocker, it’s a little more time sensitive.

abzokhattab commented 5 days ago

I see i thought its a normal issue. then i will work on it now

srikarparsi commented 5 days ago

Awesome, thank you!

jayeshmangwani commented 5 days ago

@abzokhattab I noticed you're actively engaged with this issue and have updated a proposal just few minuted ago. Could you focus on this Deploy Blocker instead of introducing new proposals on other Issue?

abzokhattab commented 5 days ago

@abzokhattab I noticed you're actively engaged with https://github.com/Expensify/App/issues/51050and have updated a proposal just few minuted ago. Could you focus on this Deploy Blocker instead of introducing new proposals on other Issue?

not actively engaged with this issue!! i am working on the current bug and that comment was pushed while the IOS is building

The pr will be ready in a few mins.

Thanks.

abzokhattab commented 5 days ago

There we go https://github.com/Expensify/App/pull/51064 🎉 Thanks for your patience

jayeshmangwani commented 5 days ago

Thanks, I am starting testing

srikarparsi commented 5 days ago

PR merged, requested CP

marcaaron commented 4 days ago

@luacmartins @srikarparsi please remove the deploy blocker label and check this off whenever we confirm the fix worked.

srikarparsi commented 4 days ago

Fix worked

https://github.com/user-attachments/assets/0013c8ec-3301-4cc2-94d7-3b3b221c0e90

melvin-bot[bot] commented 4 days ago

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

melvin-bot[bot] commented 4 days ago

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

If no regressions arise, payment will be issued on 2024-10-25. :confetti_ball:

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

melvin-bot[bot] commented 4 days ago

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:

melvin-bot[bot] commented 1 day ago

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

If no regressions arise, payment will be issued on 2024-10-29. :confetti_ball:

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

melvin-bot[bot] commented 1 day ago

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: