Skip to content

[Due for payment 2026-03-02] iOS - Company cards - Tapping the X in the input field closes the keyboard #82363

Closed

Description

@jponikarchuk

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.3.18.2
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-5134/folder/13176706/68951928/1186708657?sort=%2Bidentifier
Email or phone of affected tester (no customers): n/a
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: iPhone 13 iOS 26.2.1
App Component: Workspace Settings

Action Performed:

Preaconditions:
Do NOT use applausetester+ccardfeed@applause.expensifail.com
Workspace has an active card feed. (Use plaid card feed)

  1. Open the app
  2. Navigate to Workspace Settings > Company Cards
    3.Click on the search input field
  3. Enter something in the input field
  4. Verify the keyboard is opened
  5. Tap the X to clear the search

Expected Result:

Tapping the X clears the inpit field and the keyboard stays opened

Actual Result:

Tapping the X closes the keyboard, to clear the input field the user needs to tap again

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @lydiabarclay

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 13, 2026
  2. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 13, 2026
  3. melvin-bot commented on Feb 13, 2026

    @melvin-bot

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

  4. melvin-bot commented on Feb 13, 2026

    @melvin-bot

    Triggered auto assignment to @lydiabarclay (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.

  5. melvin-bot commented on Feb 13, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  6. daledah commented on Feb 13, 2026

    @daledah
    Contributor

    Proposal

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

    Tapping the X closes the keyboard, to clear the input field the user needs to tap again.

    What is the root cause of that problem?

    The TextInputClearButton component uses onMouseDown with e.preventDefault() to prevent losing focus when clicking the clear button, but this only works on web platforms. On native mobile (iOS/Android), the onMouseDown event doesn't exist - when the user taps the clear button (X), the tap causes the TextInput to lose focus, which dismisses the keyboard.

    <PressableWithoutFeedback
    style={[styles.mt4, styles.mh1, style]}
    accessibilityRole={CONST.ROLE.BUTTON}
    accessibilityLabel={translate('common.clear')}
    onMouseDown={(e) => {
    e.preventDefault();
    }}
    onPress={onPressButton}

    The PressableWithoutFeedback component receives the tap, which triggers the native responder system and causes the TextInput to blur before onPress is executed.

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

    We should refocus the TextInput after clearing the input on native platforms. We can achieve this by passing an inputRef to the TextInputClearButton and calling inputRef.current?.focus() after clearing the input.

    Update TextInputClearButton to accept an optional inputRef:

    -type TextInputClearButtonProps = WithSentryLabel & {
    +type TextInputClearButtonProps = WithSentryLabel & {
         style?: StyleProp<ViewStyle>;
         onPressButton: () => void;
    +    inputRef?: React.RefObject<TextInput | null>;
     };
    
    -function TextInputClearButton({style, onPressButton, sentryLabel}: TextInputClearButtonProps) {
    +function TextInputClearButton({style, onPressButton, sentryLabel, inputRef}: TextInputClearButtonProps) {
         // ...
         <PressableWithoutFeedback
             // ...
    -        onPress={onPressButton}
    +        onPress={() => {
    +            onPressButton();
    +            inputRef?.current?.focus();
    +        }}
             // ...
         >

    Then pass the input ref from BaseTextInput (in index.native.tsx) to TextInputClearButton:

     <TextInputClearButton
         onPressButton={() => {
             setValue('');
             onClearInput?.();
         }}
         style={[StyleUtils.getTextInputIconContainerStyles(hasLabel, false, verticalPaddingDiff)]}
    +    inputRef={input}
     />

    What alternative solutions did you explore? (Optional)

    1. Use Keyboard.dismiss() prevention: React Native doesn't provide a direct way to prevent keyboard dismissal when tapping outside the input.

    2. Use keyboardShouldPersistTaps="handled": This is typically used on ScrollView/FlatList containers but wouldn't work here since the clear button is part of the TextInput component itself.

    3. Platform-specific component: Create a native-specific TextInputClearButton that handles the focus differently, but the refocus approach is simpler and works across all platforms without code duplication.

    The recommended solution (refocusing the input after clearing) is the simplest and most reliable approach that maintains consistent behavior across all platforms.

  7. Eskalifer1 commented on Feb 13, 2026

    @Eskalifer1
    Contributor

    Proposal

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

    iOS - Company cards - Tapping the X in the input field closes the keyboard

    What is the root cause of that problem?

    We don't pass the keyboardShouldPersistTaps prop anywhere on the page, so onBlur always fires on the first click, even if we click on an element inside the input:

    const headerButtonsComponent = showTableHeaderButtons ? (
    <View style={shouldUseNarrowTableLayout && styles.mb5}>
    <WorkspaceCompanyCardsTableHeaderButtons
    isLoading={isLoading}
    policyID={policyID}
    feedName={feedName}
    showTableControls={showTableControls}
    CardFeedIcon={cardFeedIcon}
    />
    </View>
    ) : undefined;

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

    We need to pass this props to Table.Body, then the input will remain in focus when attempting to clear the field:

    <FlashList<T>
    data={filteredAndSortedData}
    ListEmptyComponent={isEmptyResult ? EmptyResultComponent : ListEmptyComponent}
    contentContainerStyle={[filteredAndSortedData.length === 0 && styles.flex1, listContentContainerStyle, contentContainerStyle]}
    // eslint-disable-next-line react/jsx-props-no-spreading
    {...restListProps}
    />

    keyboardShouldPersistTaps="handled"

    PS: This can be done dynamically and controlled via props if we don't want this behavior throughout the project.

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  8. abbasifaizan70 commented on Feb 13, 2026

    @abbasifaizan70
    Contributor

    Proposal

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

    In Workspace Settings > Company Cards, when the user taps the search input, types something, and then taps the X to clear the search

    What is the root cause of that problem?

    On iOS, when the user taps the clear (X) button, the touch target is the PressableWithoutFeedback inside TextInputClearButton. That press moves focus from the TextInput to the clear button. The TextInput loses focus, so iOS dismisses the keyboard. The clear handler then runs (setValue(''), onClearInput?.()), so the field is cleared but the keyboard has already been dismissed.

    The relevant clear-button handling lives in the native BaseTextInput implementation. The clear button is rendered here:

    {((isFocused && !isReadOnly && shouldShowClearButton) || !shouldHideClearButton) && !!value && !inputProps.isLoading && (
    <TextInputClearButton
    onPressButton={() => {
    setValue('');
    onClearInput?.();
    }}
    style={[StyleUtils.getTextInputIconContainerStyles(hasLabel, false, verticalPaddingDiff)]}
    />
    )}

    No refocus is performed after clearing, so the input remains unfocused and the keyboard stays closed.

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

    Refocus the text input after clearing in the native BaseTextInput implementation so the keyboard remains open. Use setTimeout(..., 0) to schedule the focus after the clear button’s press handling completes, so the input reliably receives focus again.

    {((isFocused && !isReadOnly && shouldShowClearButton) || !shouldHideClearButton) && !!value && !inputProps.isLoading && (
    <TextInputClearButton
    onPressButton={() => {
    setValue('');
    onClearInput?.();
    }}
    style={[StyleUtils.getTextInputIconContainerStyles(hasLabel, false, verticalPaddingDiff)]}
    />
    )}

                                 {((isFocused && !isReadOnly && shouldShowClearButton) || !shouldHideClearButton) && !!value && !inputProps.isLoading && (
                                     <TextInputClearButton
                                         onPressButton={() => {
                                             setValue('');
                                             onClearInput?.();
    +                                        // Refocus the input so the keyboard stays open on iOS when clearing
    +                                        setTimeout(() => {
    +                                            input.current?.focus();
    +                                        }, 0);
                                         }}
                                         style={[StyleUtils.getTextInputIconContainerStyles(hasLabel, false, verticalPaddingDiff)]}
                                     />
                                 )}

    This keeps the keyboard open after tapping the X in Company Cards (and any other screen that uses TextInput with the clear button on native).

  9. github-actions commented on Feb 13, 2026

    @github-actions
    Contributor

    ⚠️ @abbasifaizan70 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  10. lydiabarclay commented on Feb 13, 2026

    @lydiabarclay
    Contributor
  11. 13 remaining items

  12. melvin-bot commented on Feb 23, 2026

    @melvin-bot

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

  13. melvin-bot commented on Feb 23, 2026

    @melvin-bot

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

    If no regressions arise, payment will be issued on 2026-03-02. 🎊

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

    • @suneox requires payment through NewDot Manual Requests
    • @Eskalifer1 requires payment (Needs manual offer from BZ)
  14. melvin-bot commented on Feb 23, 2026

    @melvin-bot

    @suneox @lydiabarclay The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  15. lydiabarclay commented on Mar 2, 2026

    @lydiabarclay
    Contributor

    @suneox please fill out the BZ checklist!

  16. lydiabarclay commented on Mar 2, 2026

    @lydiabarclay
    Contributor

    Payment Summary

    Contributor: @Eskalifer1 paid $250 via Upwork
    Contributor+: @suneox due $250 via NewDot

    ✅ No regression test needed

  17. Eskalifer1 commented on Mar 2, 2026

    @Eskalifer1
    Contributor

    Hi everyone!

    While working on another task, I noticed a very similar bug on the Expensify cards page. The problem is the same here:

    1. When you click the “X” button, the keyboard closes and the input loses focus.
    2. There is a hint in the keyboard (autoCorrect) that is not present on the company Cards page. Also, because of these hints, if you enter incorrect text, the first tap on x will be ignored.

    Here is the bug report itself:

    2026-03-02.23.03.58.mov

    I think that since I have already worked on a similar task and it was successfully completed, and I found a similar bug, we can follow up and fix this bug as well. I already had experience with this kind of work when the original bug was fixed, but several similar ones were found when the main PR was already merged, and as far as I know, this is normal practice. Either a separate task is created, or it is done within the same task, simply changing the price. What do you think about it @suneox @chiragsalian?

    Here is the solution for this specific case:

    <ScrollView
    addBottomSafeAreaPadding
    showsVerticalScrollIndicator={false}
    >

    keyboardShouldPersistTaps="handled"

    <TextInput
    label={label}
    accessibilityLabel={label}
    role={CONST.ROLE.PRESENTATION}
    value={inputValue}
    onChangeText={onChangeText}
    inputMode={CONST.INPUT_MODE.TEXT}
    selectTextOnFocus
    spellCheck={false}
    icon={inputValue?.length ? undefined : (icon ?? expensifyIcons.MagnifyingGlass)}
    iconContainerStyle={styles.p0}
    onSubmitEditing={() => onSubmitEditing?.(inputValue)}
    shouldShowClearButton
    shouldHideClearButton={!inputValue?.length}
    />

    autoCorrect={autoCorrect} // get this from props

    Regarding the second point, we can discuss what behavior we want autoCorrect to have or not, since on iOS, the default behavior is that the first click will highlight the suggestion. Here are two videos I recorded:

    1. Without autoCorrect, there is no top menu above the keyboard. Clearing occurs on the first click:
    2026-03-02.23.23.31.mov
    1. With autoCorrect. The first click replaces the text with the correct one, and only the second click clears it:
    2026-03-02.23.23.10.mov

    As far as I understand, autoCorrect is currently enabled throughout the entire project, so we may not need to change anything. Only the Company cards page is different, and autoCorrect is disabled there. But if it is needed on some pages and not on others, you can add props and control it through props. Or we can change the approach on the Company cards page to match the approach across the entire project.

  18. suneox commented on Mar 3, 2026

    @suneox
    Contributor

    BugZero Checklist

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      https://github.com/Expensify/App/pull/77788/changes#r2878106249

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

      N/A: It isn't an impactful bug

  19. suneox commented on Mar 3, 2026

    @suneox
    Contributor

    I think that since I have already worked on a similar task and it was successfully completed, and I found a similar bug, we can follow up and fix this bug as well. I already had experience with this kind of work when the original bug was fixed, but several similar ones were found when the main PR was already merged, and as far as I know, this is normal practice. Either a separate task is created, or it is done within the same task, simply changing the price. What do you think about it @suneox @chiragsalian?

    @Eskalifer1 Currently, the scope of this issue has been resolved. If we identify another place that isn’t covered by the current solution, we can certainly review your new proposal, but your RCA between SearchBar and TableSearchBar doesn’t show a clear distinction. Therefore, it would be better to open a new issue with a detailed RCA specific to that case.

  20. lydiabarclay commented on Mar 3, 2026

    @lydiabarclay
    Contributor

    Closing, payment summary here

  21. trjExpensify commented on Mar 6, 2026

    @trjExpensify
    Contributor

    approved $250 for @suneox

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions