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

[$500] Profile - Contact method - App does not refocus to magic code on canceling contact method remove #28590

Closed
5 of 6 tasks
izarutskaya opened this issue Oct 2, 2023 · 16 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@izarutskaya
Copy link

izarutskaya commented Oct 2, 2023

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


Action Performed:

  1. Open the app
  2. Open settings->profile->contact method
  3. Open pending contact method or add new contact method and open it
  4. Click on remove and in popup, click on cancel
  5. Observe that app does not refocus on magic code input

Expected Result:

App should refocus on magic code input when we cancel remove as we do for composer when we cancel deleting any message

Actual Result:

App does not refocus to magic code on canceling contact method remove

Workaround:

Unknown

Platforms:

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

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

Version Number: v1.3.75-8

Reproducible in staging?: Y

Reproducible in production?: N

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

windows.chrome.no.refocus.on.magic.code.after.cancel.remove.mp4
android.chrome.app.does.not.refocus.to.magic.code.on.remove.cancel.mp4
android.native.app.does.not.refocus.to.magic.code.on.remove.cancel.mov
ios.safari.native.app.does.not.refocus.to.magic.code.on.remove.cancel.mov
mac.chrome.desktop.app.does.not.refocus.to.magic.code.on.remove.cancel.mov
Recording.1678.mp4

Expensify/Expensify Issue URL:

Issue reported by: @dhanashree-sawant

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01acef7fd06fbd423e
  • Upwork Job ID: 1708775391646695424
  • Last Price Increase: 2023-10-02
@izarutskaya izarutskaya added DeployBlockerCash This issue or pull request should block deployment 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 Oct 2, 2023
@melvin-bot melvin-bot bot changed the title Profile - Contact method - App does not refocus to magic code on canceling contact method remove [$500] Profile - Contact method - App does not refocus to magic code on canceling contact method remove Oct 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 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

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

melvin-bot bot commented Oct 2, 2023

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

@izarutskaya
Copy link
Author

Not reproduced on Production

Recording.1679.mp4

@saranshbalyan-1234
Copy link
Contributor

Proposal

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

App does not refocus to magic code on canceling contact method remove

What is the root cause of that problem?

Focus method is not called here

toggleDeleteModal(isOpen) {
this.setState({isDeleteModalOpen: isOpen});
Keyboard.dismiss();
}

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

Need go call focus method with setTimeout

    toggleDeleteModal(isOpen) {
        this.setState({isDeleteModalOpen: isOpen});
        Keyboard.dismiss();
        setTimeout(() => this.validateCodeFormRef.current.focus(), 400);
    }

Setimeout is required as page is currently re-rendering while modal is being closed.

What alternative solutions did you explore? (Optional)

N/A

@dukenv0307
Copy link
Contributor

dukenv0307 commented Oct 2, 2023

Proposal

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

Profile - Contact method - App does not refocus to magic code on canceling contact method remove

What is the root cause of that problem?

We don't have the logic to refocus the input when the confirm modal is closed

<ConfirmModal
title={this.props.translate('contacts.removeContactMethod')}
onConfirm={this.confirmDeleteAndHideModal}
onCancel={() => this.toggleDeleteModal(false)}
prompt={this.props.translate('contacts.removeAreYouSure')}
confirmText={this.props.translate('common.yesContinue')}
cancelText={this.props.translate('common.cancel')}
isVisible={this.state.isDeleteModalOpen && !isDefaultContactMethod}

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

We should add onModalHide prop for ConfirmModal that will be triggered after the modal is closed to refocus the input

onModalHide={() => InteractionManager.runAfterInteractions(() => {
    this.validateCodeFormRef.current.focus();
})}

<ConfirmModal
title={this.props.translate('contacts.removeContactMethod')}
onConfirm={this.confirmDeleteAndHideModal}
onCancel={() => this.toggleDeleteModal(false)}
prompt={this.props.translate('contacts.removeAreYouSure')}
confirmText={this.props.translate('common.yesContinue')}
cancelText={this.props.translate('common.cancel')}
isVisible={this.state.isDeleteModalOpen && !isDefaultContactMethod}

What alternative solutions did you explore? (Optional)

NA

Result

Screencast.from.02-10-2023.16.47.48.webm

@OSBotify
Copy link
Contributor

OSBotify commented Oct 2, 2023

👋 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.

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

Triggered auto assignment to @madmax330 (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@mountiny
Copy link
Contributor

mountiny commented Oct 2, 2023

@dukenv0307 @saranshbalyan-1234 thanks for your proposals, in any deploy blocker case, please link the PR which caused the regression. Can you please do so?

@ayazalavi
Copy link
Contributor

Proposal

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

Code field not focusing once remove popover gets closed.

What is the root cause of that problem?

Root cause is that we are not handling modal open and close event in
https://github.com/Expensify/App/blob/main/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.js

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

Add key ONYXKEYS.MODAL in below file that will allow us to listen for modal open and close events.

Once above is done we need to listen for updates in modal props in

componentDidUpdate(prevProps) {
const validatedDate = lodashGet(this.props.loginList, [this.getContactMethod(), 'validatedDate']);
const prevValidatedDate = lodashGet(prevProps.loginList, [this.getContactMethod(), 'validatedDate']);
// Navigate to methods page on successful magic code verification
// validatedDate property is responsible to decide the status of the magic code verification
if (!prevValidatedDate && validatedDate) {
Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS);
}
}

Adding following code at the bottom of the function will fix the problem. It is checking if modal is closed and isDeleteModalOpen state variable is false, then it is checking whether form has code input by checking this.validateCodeFormRef.current and also whether focus method can be called safely below:

if (!prevProps.modal.willAlertModalBecomeVisible && !nextProps.isDeleteModalOpen) {
            if (this.validateCodeFormRef.current && this.validateCodeFormRef.current.hasOwnProperty('focus') && typeof this.validateCodeFormRef.current.focus === 'function') {
                this.validateCodeFormRef.current.focus()
            }
        }

What alternative solutions did you explore? (Optional)

N/A

@dukenv0307
Copy link
Contributor

@mountiny This coming from this PR since blur the the input when clicking outside #24012

@mountiny mountiny added Awaiting Payment Auto-added when associated PR is deployed to production and removed Help Wanted Apply this label when an issue is open to proposals by contributors labels Oct 2, 2023
@mountiny
Copy link
Contributor

mountiny commented Oct 2, 2023

The PR was reverted and this is not a blcoker anymore https://expensify.slack.com/archives/C9YU7BX5M/p1696260504107759?thread_ts=1696257638.565279&cid=C9YU7BX5M

I believe the only pending thing here @peterdbarkerUK is to pay $50 to @dhanashree-sawant for reporting this blocker

@wojtus7 wojtus7 mentioned this issue Oct 3, 2023
57 tasks
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Oct 3, 2023
@peterdbarkerUK
Copy link
Contributor

Offer sent @dhanashree-sawant

@dhanashree-sawant
Copy link

Thanks @peterdbarkerUK, I have accepted the offer.

@peterdbarkerUK
Copy link
Contributor

Sweet

Reporter: $50 paid to @dhanashree-sawant

Thanks for your continued prolific work @dhanashree-sawant!

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. Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

10 participants