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

[$250] IOS - Expense/IOU - Keyboard overlaps camera when replacing receipt #51063

Open
1 of 8 tasks
lanitochka17 opened this issue Oct 17, 2024 · 11 comments
Open
1 of 8 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

@lanitochka17
Copy link

lanitochka17 commented Oct 17, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.50
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

  1. Open the app and log in
  2. Navigate to any chat
  3. Tap + > Submit expense > Manual
  4. Enter the amount, add the receipt on the confirmation step and submit IOU/expense
  5. Navigate to the IOU/expense details
  6. While the keyboard is up, scroll up and tap the receipt
  7. Select 3 dots > Replace

Expected Result:

The keyboard is hidden

Actual Result:

The keyboard is still displayed and overlaps the camera

Workaround:

Unknown

Platforms:

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

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6638131_1729195839730.IMG_0494.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021849498756209836053
  • Upwork Job ID: 1849498756209836053
  • Last Price Increase: 2024-10-24
Issue OwnerCurrent Issue Owner: @suneox
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 17, 2024
Copy link

melvin-bot bot commented Oct 17, 2024

Triggered auto assignment to @JmillsExpensify (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 melvin-bot bot added the Overdue label Oct 21, 2024
@c3024
Copy link
Contributor

c3024 commented Oct 21, 2024

Proposal

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

Keyboard overlaps with camera view when replacing receipt.

What is the root cause of that problem?

When we click on Replace in AttachmentModal, we execute closeModal first and then navigate to the receipt selection scan page.

closeModal();
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
CONST.IOU.ACTION.EDIT,
iouType,
transaction?.transactionID ?? '-1',
report?.reportID ?? '-1',
Navigation.getActiveRouteWithoutParams(),
),
);

This closeModal executes onModalClose if it is a function
const closeModal = useCallback(() => {
setIsModalOpen(false);
if (typeof onModalClose === 'function') {
onModalClose();
}

We dismiss the attachment modal in TransactionReceiptPage here in onModalClose
Navigation.dismissModal();
} else {
Navigation.dismissModal(
ReportUtils.isOneTransactionThread(report?.reportID ?? '-1', report?.parentReportID ?? '-1', parentReportAction) ? report?.parentReportID : report?.reportID,
);
}

When we dispatch two such navigation actions (dismissModal and navigate to scan page) one after another immediately, we cannot be sure of the order in which they execute and the actions seem to be interfere with each other.

navigationRef.dispatch with StackActions.pop() used in dismissModal involves a little more complex process of action handling, so this issue is most evident when using dismissModal. A similar issue is seen here.

Using goBack instead of dismissModal reduces this largely but still there are chances of unexpected order.

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

We should wait for the navigation actions in onModalClose to complete before sending new navigation actions.
So, we can change this

Navigation.navigate(

to

Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(

so that the next navigation action is added to the micro task queue and gets executed only after the previous navigation action is complete.

What alternative solutions did you explore? (Optional)

Copy link

melvin-bot bot commented Oct 21, 2024

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

Copy link

melvin-bot bot commented Oct 23, 2024

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

@JmillsExpensify
Copy link

Opening up to the community.

@melvin-bot melvin-bot bot removed the Overdue label Oct 24, 2024
@JmillsExpensify JmillsExpensify added the External Added to denote the issue can be worked on by a contributor label Oct 24, 2024
Copy link

melvin-bot bot commented Oct 24, 2024

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

@melvin-bot melvin-bot bot changed the title IOS - Expense/IOU - Keyboard overlaps camera when replacing receipt [$250] IOS - Expense/IOU - Keyboard overlaps camera when replacing receipt Oct 24, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 24, 2024
Copy link

melvin-bot bot commented Oct 24, 2024

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

@suneox
Copy link
Contributor

suneox commented Oct 25, 2024

@c3024 Thank you for your proposal. However, your RCA isn’t clear about which event or referenced code is triggering the input focus that opens the keyboard. Could you please provide more information on that point?

@c3024
Copy link
Contributor

c3024 commented Oct 25, 2024

When we go to a report without any messages, composer autofocuses here

(shouldFocusInputOnScreenFocus || (isEmptyChat && !ReportActionsUtils.isTransactionThread(parentReportAction))) &&

So, when we close the attachment modal we return to the money request report and the money request view is not considered a message so the composer autofocuses and the keyboard shows up.

I think when the navigation actions are dispatched simultaneously and not successively, the focus seems to trigger later than the second navigation action (here opening the scan page) or the next navigation to scan page happens before the blurring of the composer and the keyboard remains visible.

@shahinyan11
Copy link
Contributor

shahinyan11 commented Oct 25, 2024

@suneox Hi there. I posted a proposal for this issue a week ago, but somehow it was posted under a different issue. I must have mixed up the issues and posted the solution in the wrong place. I don't know if you'll take this into account, but I'll add my suggestion here too. Thank you

@shahinyan11
Copy link
Contributor

Proposal

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

IOS - Expense/IOU - Keyboard overlaps camera when replacing receipt

What is the root cause of that problem?

On pressing replace in the three-dot menu we call the closeModal function here before navigation. The closeModal in turn calls the onModalClose function from the component props and it calls Navigation.dismissModal inside ( See here ).
Above implementation leads to keyboard activation on report screen before navigation to new screen

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

  1. Add optional shouldCallParentClose param for closeModal function and update function body to below
    const closeModal = useCallback(( shouldCallParentClose =  true) => {
        setIsModalOpen(false);

        if (typeof onModalClose === 'function' && shouldCallParentClose) {
            onModalClose();
        }

        // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
    }, [onModalClose]);
  1. Call the closeModal function with false parameter .

  2. OPTIONAL: Move closeModal(false) under Navigation.navigate

onSelected: () => {
    Navigation.navigate(
        ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
            CONST.IOU.ACTION.EDIT,
            iouType,
            transaction?.transactionID ?? '-1',
            report?.reportID ?? '-1',
            Navigation.getActiveRouteWithoutParams(),
        ),
    );
    closeModal(false);
},

What alternative solutions did you explore? (Optional)

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
Status: No status
Development

No branches or pull requests

5 participants