Skip to content

Android - Expense - List dopdown auto closes after focusing on text field and opening list #101802

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.91-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: github.com//pull/100735
Email or phone of affected tester (no customers): sjodjoijsonjoinj@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Samsung Galaxy S25 FE / Android 16
App Component: Money Requests

Action Performed:

Precondition:

  • Create text and list type report field.
  1. Launch Expensify app.
  2. Go to workspace chat.
  3. Create an expense.
  4. Open the expense.
  5. Tap on the text report field.
  6. Tap list report field.

Expected Result:

List dopdown will not auto close after focusing on text field and opening list.

Actual Result:

List dopdown auto closes after focusing on text field and opening list.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7265679_1790019364086.6.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Svetlana Lazutkina
Bug ID: 7265679

Activity

  1. applause-bot commented on Sep 21, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/7c9de857ac9abc472498019075a96e7e65dc993c1edf4d8b4bf15f242667ff14

  2. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 21, 2026
  3. melvin-bot commented on Sep 21, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #100735

  4. github-actions commented on Sep 21, 2026

    @github-actions

    👋 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.
  5. melvin-bot commented on Sep 21, 2026

    @melvin-bot

    @Gonals @daledah you have been assigned to this deploy blocker because you reviewed the offending PR: #100735

  6. melvin-bot commented on Sep 21, 2026

    @melvin-bot

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

  7. MelvinBot commented on Sep 21, 2026

    @MelvinBot

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: Show up to three report fields per row and edit them inline (Expensify/App#100735) by @daledah (High confidence)
    Related Issues: Android - Expense - Report field value jumps when navigating from one report to another (Expensify/App#101798), Android - Expense - Report auto scrolls to bottom after opening report field (Expensify/App#101799) — both also Android, both also in the new inline report-field UI from the same PR

    Recommendation: REVERT

    This PR is the sole source of the inline report-field editor and has produced three Android deploy blockers in one release; a targeted fix would have to change FilterPopupButton, which is shared by the Search filter bar and the Table filter bar, and that is not a safe change to land mid-deploy. Reverting removes all three blockers at once and the feature can re-land with the dropdown open made idempotent.

    Assigned: @daledah (PR author), @Gonals (approving reviewer) from highest-confidence causing PR only — already assigned by melvin-bot, no change needed
    Labels: No changes. DeployBlockerCash is kept (App PR caused it, fix lands in Expensify/App). DeployBlocker is not present, so nothing to remove.

    📋 Detailed Analysis

    Evidence

    • Reproducible on staging, not on production, and Expensify/App#100735 is on the 9.4.91-0 Deploy Checklist: New Expensify 2026-09-21.
    • Before this PR, report fields in the report view were MenuItem rows that navigated to DynamicEditReportFieldPage. There was no inline text input and no inline list dropdown, so the code path in the repro steps did not exist in production. The PR creates src/components/MoneyRequestReportView/ReportFieldInlineInput.tsx (new file, +246) and rewrites MoneyReportView.tsx (+19/−64) to use it.
    • Two sibling deploy blockers filed against the same build (Expensify/App#101798, Expensify/App#101799) are also Android report-field bugs in this same new component.
    • Within the PR's own history the dropdown was first implemented with a local isOptionListVisible state opened by the idempotent setIsOptionListVisible(true), and was then refactored to FilterPopupButton, which replaced that with a toggle. That refactor is where the regression enters.

    Verification

    Affected files, all touched by Expensify/App#100735:

    Pre-existing files the new code newly depends on (unchanged by the PR, but only now reachable from a report field):

    Root Cause

    FilterPopupButton has no open action — it only has a toggle, and it hands that same toggle out under three different names:

    FilterPopupButton.tsx#L81-L112 — toggleOverlay is passed as the trigger's onPress, as the popover's onClose, and as closeOverlay to the popover content. Every one of those flips the state rather than setting it, so a second invocation of the "open" action closes the dropdown.

    That was safe for every pre-existing consumer, because all of them (DropdownButton, TableFilterTrigger, SearchAdvancedFiltersButton, TableDisplaySettingsTrigger, …) render a Button as the trigger: one unambiguous press path, no keyboard involved.

    ReportFieldInlineInput is the first consumer to render a TextInput as the trigger, and it binds the toggle to two trigger props at once:

    ReportFieldInlineInput.tsx#L216-L218

    onPress={onPress}
    onBlur={() => setHasBeenBlurred(true)}
    onSubmitEditing={onPress}

    A TextInput already has more than one press path on native — BaseTextInput wires the consumer's onPress both to the wrapping PressableWithoutFeedback (index.native.tsx#L315-L317) and to the inner input's onPressOut (index.native.tsx#L441) — and onSubmitEditing adds a third. With an idempotent setVisible(true) that redundancy is harmless; with a toggle, the second trigger closes the dropdown.

    What makes the failure Android-only and dependent on step 5 (focusing the text field first) is that the open becomes asynchronous and re-entrant exactly when a soft keyboard is up:

    src/utils/keyboard/index.android.ts#L50-L69

    const dismissKeyboardAndExecute = (cb: () => void): Promise<void> => {
        return new Promise((resolve) => {
            if (!isVisible) {
                cb();
                resolve();
                return;
            }
    
            const keyboardDidHideSubscription = KeyboardEvents.addListener('keyboardDidHide', (e) => {
                if (e.height !== 0) {
                    resolve();
                    return;
                }
                cb();
                keyboardDidHideSubscription.remove();
                resolve();
            });
            Keyboard.dismiss();
        });
    };

    FilterPopupButton routes its entire open through this (#L96-L106). With no keyboard up, cb() runs synchronously and a single tap produces a single toggle, which is why the list field works when you tap it directly. After step 5 the keyboard is up, so:

    1. toggleOverlay() is deferred behind a keyboardDidHide listener.
    2. Any further trigger (onSubmitEditing, or the second press path) reaches toggleOverlay after the deferred one has already opened the dropdown, flipping it straight back closed — the reported "auto closes".
    3. The deferral is additionally unsound: the "is the keyboard up?" flag isVisible is maintained from React Native's Keyboard events (#L14-L20) while the wait is on react-native-keyboard-controller's KeyboardEvents. These fire at different times on Android, and focusing the list input (showSoftInputOnFocus={false} via disableKeyboard) already starts hiding the keyboard before onPress runs. On the e.height !== 0 branch the listener is never removed, so a stale cb() can fire on a later keyboard hide and toggle the dropdown shut.

    DatePicker — the closest analogue, also a TextInput with disableKeyboard that opens a popover — does not have this problem precisely because its open is idempotent and intent-guarded: DatePicker/index.tsx#L129-L145 uses setPickerVisibility(true) plus an openIntentRef so a deferred open is dropped if the picker was dismissed meanwhile.

    If a roll-forward is preferred over a revert, the minimal change is to stop using a toggle as the open action:

    • In FilterPopupButton, split toggleOverlay into openOverlay (setIsOverlayVisible(true)) and closeOverlay (setIsOverlayVisible(false)), pass openOverlay as the trigger's onPress, and pass the real closeOverlay (not the toggle) as both onClose and the closeOverlay prop given to PopoverComponent.
    • Guard the deferred open in calculatePopoverPositionAndToggleOverlay with an intent ref, mirroring DatePicker's openIntentRef, and bail out if another trigger already opened it.
    • In ReportFieldInlineInput, do not bind the same handler to both onPress and onSubmitEditing.

    Note also that inputStyle={styles.pointerEventsNone} on the trigger (#L211) is a no-op: BaseTextInput appends styles.pointerEventsAuto after inputStyle in the style array, so the inner input stays tappable and its onPressOut path stays live. That is pre-existing (DatePicker does the same), but it is why the "taps only reach the wrapper" assumption does not hold here.

    What remains unverified: I could not run this on an Android device, so the exact ordering of the second trigger (onSubmitEditing versus the inner onPressOut/wrapper onPress pair) and the precise keyboardDidHide interleaving between RN Keyboard and react-native-keyboard-controller are inferred from the code rather than observed. The defect being fixed — a toggle used as an open action, reached from multiple triggers and deferred asynchronously — holds regardless of which of those wins the race.

    💡 Suggested AI code review rule

    This bug looks like a recurring, mechanically detectable pattern, so it may be worth a coding-standards rule so the AI reviewer catches the next one. Proposed for Expensify/App:

    • Rule: CLEAN-REACT-PATTERNS-10 — Open and close overlays with explicit actions, never a shared toggle
    • Condition: Flag a component that exposes or binds a setX(prev => !prev) toggle as its open or close action — including passing one toggle as both onPress/onClose/closeOverlay, or binding the same handler to more than one trigger prop on a single control (onPress + onSubmitEditing). Use separate idempotent open()/close() setters instead, and guard any asynchronously deferred open with an intent ref.
    • Why: A toggle is only correct when every trigger is guaranteed to fire exactly once. Controls with multiple press paths (a TextInput wires onPress to both its wrapper Pressable and the inner input's onPressOut) and asynchronously deferred opens (KeyboardUtils.dismissKeyboardAndExecute on Android) both break that guarantee, so the second trigger closes what the first just opened. Incident: this issue.
    • Search pattern: setIsOverlayVisible\(\(?\w+\)? => ! / set\w+\(prev => !prev\) whose result is passed to a prop named open*, close*, or onClose; and the same identifier appearing in two trigger props on one JSX element, e.g. onPress=\{(\w+)\}[\s\S]{0,200}onSubmitEditing=\{\1\}
    • Offending code (❌): ReportFieldInlineInput.tsx#L216-L218 and FilterPopupButton.tsx#L81-L112
    • Fix (✅): the existing idempotent + intent-guarded pattern in DatePicker/index.tsx#L109-L145

    The full rule file, with the ❌/✅ code inline in Expensify/App's app-coding-standards format, would go in Expensify/App itself. If it's worth adding, a maintainer can open it there as a draft PR.

  8. melvin-bot commented on Sep 21, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  9. melvin-bot commented on Sep 21, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  10. melvin-bot commented on Sep 22, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  11. Gonals commented on Sep 22, 2026

    @Gonals

    PR Reverted

  12. IuliiaHerets commented on Sep 22, 2026

    @IuliiaHerets

    Xiaomi Redmi Note 10 / Android 12
    9.4.91-1
    Not repro

    Screenrecorder-2026-09-22-14-15-01-465.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions