Skip to content

fix:67907: autofocus inputs in PerDiem and Amount page - #69380

Merged
madmax330 merged 5 commits into
Expensify:mainfrom
Eskalifer1:fix/67907
Sep 18, 2025
Merged

madmax330 merged 5 commits into
Expensify:mainfrom
Eskalifer1:fix/67907

Conversation

@Eskalifer1

@Eskalifer1 Eskalifer1 commented Aug 27, 2025 •

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR fixes autofocus inputs on the Amount and PerDiem pages when creating an expense, as focus is lost on iOS.

Fixed Issues

$#67907
PROPOSAL:#67907 (comment)

Tests

Preconditions: Have a workspace with Per Diem enabled.

  1. Tap the FAB (Floating Action Button)
  2. Navigate to the Per Deim tab
  3. Make sure input is autofocused and keyboard appears
  4. Go to Amount page(first tab)
  5. Make sure caret(horizontal line after currency) is displayed
  • Verify that no errors appear in the JS console

Offline tests

Same as tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
67907-android-native.mp4
Android: mWeb Chrome
67907-android-web.mp4
iOS: Native
67907-ios-native.mp4
iOS: mWeb Safari
67907-ios-web.mp4
MacOS: Chrome / Safari
67907-web.mp4
MacOS: Desktop
67907-desktop.mp4

@Eskalifer1
Eskalifer1 requested a review from a team as a code owner August 27, 2025 17:43
@melvin-bot
melvin-bot Bot requested review from jayeshmangwani and removed request for a team August 27, 2025 17:43
@melvin-bot

melvin-bot Bot commented Aug 27, 2025

Copy link
Copy Markdown

@jayeshmangwani Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@Eskalifer1

Copy link
Copy Markdown
Contributor Author

PR is ready!

I removed autofocus from mobile devices. From the thread we had on Slack, I realized that the main problem was with the keyboard, and someone also mentioned not focusing on phones, so I realized that it was not necessary to focus only on phones. If you think we should remove the focus altogether (on PCs), let me know and I'll update the PR. Thank you!

Here is the link to Slack

cc: @jayeshmangwani

@jayeshmangwani

jayeshmangwani commented Aug 29, 2025 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android.mp4
Android: mWeb Chrome
mweb-chrome.mp4
iOS: HybridApp
ios.mp4
iOS: mWeb Safari
mweb-safari.mov
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov

@jayeshmangwani

Copy link
Copy Markdown
Contributor

I removed autofocus from mobile devices. From the thread we had on Slack, I realized that the main problem was with the keyboard, and someone also mentioned not focusing on phones, so I realized that it was not necessary to focus only on phones. If you think we should remove the focus altogether (on PCs), let me know and I'll update the PR. Thank you!

Here is the link to Slack

cc: @jayeshmangwani

I’m okay with keeping the focus on web and desktop while removing it from mobile devices due to the keyboard pop-ups. I’m looping in the @Expensify/design to see if they have a different perspective.

@dannymcclain

Copy link
Copy Markdown
Contributor

I’m okay with keeping the focus on web and desktop while removing it from mobile devices due to the keyboard pop-ups

I think that was the general consensus from the threads. @Expensify/design @Expensify/product-pr for a gut check!

@trjExpensify

Copy link
Copy Markdown
Contributor

Mhm, not sure how I feel about this. Most people using Per Diem have a ton of destination/rates, so focusing the input to search for it right away seems snappier than forcing the click or encouraging scrolling a long list of rates. 🤔 I don't see it as being any different to the participant selector step in Create expense etc.

@dubielzyk-expensify

Copy link
Copy Markdown
Contributor

I feel like I go back and forth depending on what input field it's talking about. For this one, I don't mind auto-focusing it tbh especially if the list is gonna be super long like you mention, Tom

@Eskalifer1

Copy link
Copy Markdown
Contributor Author

Okay, just let me know so i can make a proper fix

@trjExpensify

Copy link
Copy Markdown
Contributor

Yeah, my vote would be this one.

Input field should either stay in focus or not attempt autofocus at all to avoid unexpected UX.

@Eskalifer1

Copy link
Copy Markdown
Contributor Author

Okay, can I start working on the changes, or are we waiting for someone else's recommendation?

@trjExpensify

Copy link
Copy Markdown
Contributor

@dannymcclain @shawnborton you cool with this too?

@dannymcclain

Copy link
Copy Markdown
Contributor

I definitely won't stand in the way of that route, though it's not my preference haha. I feel like I'm in the minority in terms of preference, so I'm down to go with what you all think is right.

focusing the input to search for it right away seems snappier than forcing the click or encouraging scrolling a long list of rates. 🤔 I don't see it as being any different to the participant selector step in Create expense etc.

My spicy take preference is that I would rather have to click to focus on mobile (in all of these cases) than have the keyboard automatically pop up. I don't see it as being slower or less snappy—but again, I realize not everyone / maybe most people don't share that perspective so I'm happy to go with what y'all think is best!

@shawnborton

shawnborton commented Sep 2, 2025 •

Copy link
Copy Markdown
Contributor

Personally I think I generally agree with Danny's preference as a broad rule, but I also kinda agree with Jon that if we are fairly positive the user is going to need to search for something, then I don't mind autofocusing. But if we don't know for sure, I would fallback on not autofocusing.

Here I am, just sitting on the fence I guess!

@JmillsExpensify

Copy link
Copy Markdown
Contributor

Uff, I'm with Danny. I think with where we're at with RN keyboard controls, I think the auto-focus gets particularly rough on mobile. I'm also not confident we know that a user is going to want to search on this page, so I'd lean more to not doing it until it comes up as a pain point.

@trjExpensify

Copy link
Copy Markdown
Contributor

I've never known someone not have a lot of per diem rates given the nature of them, so I guess I feel more confident and lean on leaving the status quo as is until someone complains the keyboard is focused to choose their per diem rates. 😅

@jayeshmangwani

Copy link
Copy Markdown
Contributor

Oops, we’re circling back again, and it seems like we still have mixed opinions on the expected result. What’s the final call 😅, are we going with auto-focus or not?

@trjExpensify

Copy link
Copy Markdown
Contributor

My vote is yes, autoFocus the per diem rate selector page. Every other select list of sorts in Create expense is, I don't see a burning need to make an exception here.

@shawnborton

Copy link
Copy Markdown
Contributor

No strong feelings here, works for me!

@jayeshmangwani

Copy link
Copy Markdown
Contributor

Okay, so @Eskalifer1 , it seems we are going with auto-focusing. Please update the changes accordingly.

@Eskalifer1

Copy link
Copy Markdown
Contributor Author

Got it! I'll work on it today!

@jayeshmangwani Do I also need to fix the page with the amount? The focus is also lost there, but it's not noticeable because it's not a regular field and the keyboard doesn't appear, but the bug is also present

@jayeshmangwani

Copy link
Copy Markdown
Contributor

@Eskalifer1 I think we only want to fix the Per Diem tab here. I’m not sure what other bug you’re referring to - if you can share a video, I can confirm whether we should fix it here or not

@Eskalifer1

Copy link
Copy Markdown
Contributor Author

@jayeshmangwani Here is a video showing that there is a caret on the first entry, but it is missing on the second entry. This is the same RCA as for the perDiem page, so I am asking if this needs to be done.

2025-09-10.15.19.03.mov

@jayeshmangwani

Copy link
Copy Markdown
Contributor

Okay, cool - let’s solve that one here too if the RCA is the same.

@Eskalifer1 Eskalifer1 changed the title fix:67907: removed autofocus for destinationPicker on mobile fix:67907: autofocus inputs in PerDiem and Amount page Sep 10, 2025
@jayeshmangwani

Copy link
Copy Markdown
Contributor

Sorry for the delay, I’ll get to this PR soon. My local iOS tabs have been acting flaky, so I’m working on fixing that first.

@jayeshmangwani jayeshmangwani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@melvin-bot
melvin-bot Bot requested a review from madmax330 September 16, 2025 20:07
@madmax330
madmax330 merged commit e2e05b5 into Expensify:main Sep 18, 2025
23 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/madmax330 in version: 9.2.16-0 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 failure ❌

@Eskalifer1

Copy link
Copy Markdown
Contributor Author

We decided to revert changes for manual tab since this is out of scope, and this approach adds delay (as on all pages where there is focus when changing tabs with the approach used here), which negatively affects UX in this case, and if we want to fix this in the future, it is better to create a separate task for this.

As a result, this PR only fixes the focus on the PerDiem page.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.2.16-14 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/madmax330 in version: 9.2.17-0 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.2.17-6 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants