Skip to content

fix: show clear button on all SelectionList search fields - #101086

Merged
mountiny merged 4 commits into
Expensify:mainfrom
software-mansion-labs:jakubstec/add-clear-search-button-to-selectonList-search-fields
Sep 21, 2026
Merged

mountiny merged 4 commits into
Expensify:mainfrom
software-mansion-labs:jakubstec/add-clear-search-button-to-selectonList-search-fields

Conversation

@jakubstec

@jakubstec jakubstec commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Explanation of Change

SelectionList search fields never had a clear (X) button. They all render one shared component (src/components/SelectionList/components/TextInput.tsx) which never opted into it, so the X was missing on ~90 screens.

This adds shouldHideClearButton={!value} there, so every SelectionList search field shows the X once it has text, consistent with the rest of the app. Design agreed in the issue to make this global (#100841 (comment)).

Note: shouldShowClearButton is intentionally not passed as well, because it would hide the loading spinner on lists that search server-side.

Fixed Issues

$ #100841
PROPOSAL:

Tests

  1. Sign in to an account that admins 12+ workspaces (the search field only renders above CONST.STANDARD_LIST_ITEM_LIMIT items).
  2. Go to Workspaces > Domains > (domain) > Groups > (group) > Preferred workspace.
  3. Type anything into the search field.
  4. Verify an X button appears on the right-hand side of the field.
  5. Click the X and verify the field is cleared, the full workspace list comes back, and the input keeps focus.
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

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
  • 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 followed proper code patterns (see Reviewing the code)
    • 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 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)
  • 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)
  • 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 new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • 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.
  • 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

MacOS: Chrome / Safari
Screen.Recording.2026-09-14.at.16.46.29.mov
Screen.Recording.2026-09-14.at.16.47.56.mov

@jakubstec jakubstec changed the title fix: add search bar to all selection list search bars fix: show clear button on all SelectionList search fields Sep 14, 2026
@jakubstec
jakubstec force-pushed the jakubstec/add-clear-search-button-to-selectonList-search-fields branch from d39cb86 to 6d866b7 Compare September 14, 2026 12:51
@jakubstec
jakubstec force-pushed the jakubstec/add-clear-search-button-to-selectonList-search-fields branch from 6d866b7 to dc775a5 Compare September 14, 2026 12:57
@jakubstec

Copy link
Copy Markdown
Member Author

@codex review
@MelvinBot review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: dc775a5c15

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

The one-line change is correct and does what the description claims. I verified the behavior live on web — it works. Two things to address before merge, plus one nit.

1. The Screenshots/Videos sections are empty. Every <details> block still contains only the placeholder comment, while the author checklist claims screenshots were included and all five platforms were tested. For a change that alters ~90 screens, a reviewer can't approve on that. Please attach at least web + one native.

2. Confirm the spinner-vs-X behavior is intended on server-side search lists. index.tsx:546 gates the clear button on !isLoading, and BaseSelectionList.tsx:291 wires isLoading to isLoadingNewOptions. On the ~20 screens that search server-side (New chat, workspace invite, task assignee, money request participants…), isLoadingNewOptions flips on every keystroke — for example NewChatPage/index.tsx:435 — so the X will swap to the spinner and back while typing. This matches what SearchAutocompleteInput.tsx:253-254 already does, so it's consistent rather than wrong — but this PR is what makes it visible app-wide, so it's worth an explicit yes from design.

3. Nit: the new test doesn't lock in that behavior, even though the description names it as the reason for not passing shouldShowClearButton. One extra case rendering with isLoadingNewOptions and asserting the X is absent would keep a future edit from silently regressing it.

What I verified

Scope claim holds. Both BaseSelectionList and BaseSelectionListWithSections import the same SelectionList/components/TextInput.tsx, so the single prop really does cover every SelectionList search field.

No side effect from the shouldHideClearButton gating. index.tsx:575 also uses shouldHideClearButton to gate rightHandSideComponent, but this component never passes one, so nothing changes there.

Clearing goes through the normal path. The button calls setValue(''), which calls inputProps.onChangeText('') — the same path typing takes — so debounced and server-side search terms reset the same way they do when you backspace.

Focus is retained on web via the onMouseDown preventDefault in TextInputClearButton, and index.native.tsx has identical render logic, so native has parity.

Minor: shouldHideClearButton={!value} is redundant — line 546 already requires !!value, so {false} would behave identically for the clear button. Keeping !value matches BaseSearchBar.tsx:56-57, so it's fine as-is — just flagging that it isn't load-bearing.

Not run: I couldn't execute jest in this sandbox, so the new unit test wasn't run locally. The test itself reads correctly — useLocalize is mocked to return keys, so getByLabelText('common.clear') resolves, and useState is already imported in that file. CI will confirm.

Live verification on web (Settings > Profile > Timezone)

I ran this on the PR branch against a SelectionList with a long list. All three checks passed.

Empty field — no X:

Empty SelectionList search field with no X button

After typing — X appears, vertically centered, not clipping the text, field height unchanged:

SelectionList search field showing typed text with the X clear button

After pressing X — field cleared, full list restored, and typing immediately afterward landed in the search field without re-clicking it, confirming focus was kept:

Typing immediately after pressing X, showing focus was retained

The console-error check is not covered: the web driver has no console inspection command. Network traffic was all 200 and no error banners appeared, but that is a proxy, not the check itself.


Reply with @MelvinBot <your feedback> to refine this review.

@jakubstec
jakubstec marked this pull request as ready for review September 14, 2026 14:50
@jakubstec
jakubstec requested review from a team as code owners September 14, 2026 14:50
@melvin-bot
melvin-bot Bot requested review from dylanexpensify and situchan and removed request for a team and dylanexpensify September 14, 2026 14:50
@melvin-bot

melvin-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

@situchan 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]

@situchan

Copy link
Copy Markdown
Contributor

Some more places:

emoji picker new rule

These are search inputs so I think clear button is expected to show.

@MelvinBot any more missing places?

@MelvinBot

MelvinBot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Those two are the only list-filter search inputs still missing the X. I swept every text input in src and everything else already gets it.

Still missing:

Place File Note
Emoji picker search (web + desktop) EmojiPicker/EmojiPickerMenu/index.tsx:408 Needs value too — see below
Emoji picker search (native) EmojiPicker/EmojiPickerMenu/index.native.tsx:194 Same
New rule → Suggested → "Find a rule" AgentRules/AddAgentRuleSuggestionsTab.tsx:109 Already controlled — one-line fix

Gotcha on the emoji picker: shouldHideClearButton={false} alone will do nothing there. The input is uncontrolled — it passes defaultValue="" and never passes value, while the clear button is gated on the value prop at BaseTextInput/implementation/index.tsx:546. The searchText state already exists (web / native), it's just not wired to the input — so you need value={searchText} plus shouldHideClearButton={!searchText}.

Worth considering: that emoji picker input is a hand-rolled copy of CompactSearchBar — same listSearchInputNarrowWrapper/listSearchInputWideWrapper styles, same placeholder. Swapping it for CompactSearchBar fixes both platforms and removes the duplication.

How I checked, and the two judgement calls

163 files import @components/TextInput directly. Of those, the ones that filter or narrow a list are:

  • Already covered before this PR: BaseSearchBar.tsx:57 (so SearchBar + CompactSearchBar), SearchAutocompleteInput.tsx:254, SearchPageInput.tsx:88, TableSearchBar.tsx:107.
  • Covered by this PR: everything routing through SelectionList. I specifically checked the Search filter dropdowns (MultiSelect, SingleSelect, UserSelector, SearchSingleSelectionPicker), the month/year pickers, and the Debug pages — all of them render SelectionList, so they inherit the fix.
  • Not list search: AddMerchantToMatchPage, SupportalSwitcherButton, and the rest are plain form fields.

Two I left off the list deliberately, tell me if you disagree:

  1. AddressSearch/index.tsx:451 — Google Places autocomplete. It's a form field with a floating label (Address), not a field that narrows a list on screen, and it lives inside forms with their own reset behavior.
  2. TextFilterPopup.tsx, TextInputPopup.tsx, AdvancedFilters/TextInputFilterContent.tsx — value-entry fields ("merchant contains…"), applied on submit, and each popup already has a Reset button.

This was a static sweep of dc775a5 (the PR head), not a live click-through of every screen.


Reply with @MelvinBot <your feedback> to refine this.


view run · no recording available

@jakubstec

Copy link
Copy Markdown
Member Author

I've handled both cases @situchan

by the way, I've found a bug that is in production (EmojiPicker) - when you change the window size with something entered in a search, it resets an input and disappears after clicking on) cc @mountiny

Screen.Recording.2026-09-16.at.13.03.35.mov

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 5f7d1bb0e5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@MelvinBot

MelvinBot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review

Yes — both places situchan flagged are handled correctly, and the fix matches what I recommended. I verified the emoji picker live on web: the X appears once there's text, clearing restores the full categorized list, and focus is kept. CI is fully green.

Two things to tidy before merge, plus one nit.

1. The PR description doesn't cover the new changes. The Tests and QA Steps sections still only describe the Domains → Groups → Preferred workspace flow. The emoji picker search and New rule → Suggested → "Find a rule" aren't mentioned, so QA won't test them. Please add steps for both.

2. The emoji picker inputs went from uncontrolled to controlled — attach native evidence. index.tsx:422-423 replaces defaultValue="" with value={searchText}, and index.native.tsx:206-207 adds value where there was none. That's the correct fix — the clear button is gated on the value prop at BaseTextInput/implementation/index.tsx:550, so shouldHideClearButton alone would have done nothing. But it does change how the native input is driven on every keystroke, and Screenshots/Videos only has MacOS Chrome/Safari. Since index.native.tsx is now in the diff, please attach an iOS and Android clip of typing into the emoji search and clearing it.

3. Nit: shouldHideClearButton={!searchText} isn't load-bearing — line 550 already requires !!value, so {false} behaves identically. It matches BaseSearchBar.tsx:57, so it's fine as-is.

On the resize bug you filmed: worth re-checking on this branch. Making the input controlled means it can no longer diverge from searchText — previously the DOM input could reset to defaultValue="" while the filtered list stayed applied, which is exactly what your video shows. I did not reproduce the resize case, so this is a hypothesis, not a claim.

What I checked statically

All three sites are correct and complete. Relative to the list I gave above, every place is covered: emoji picker web, emoji picker native, and AddAgentRuleSuggestionsTab.tsx:114. Nothing else in src renders a list-filter input without the X.

Clearing goes through the normal typing path. The button calls setValue('') → onChangeText('') → setSearchText('') + filterEmojis(''), so the emoji list resets the same way backspacing does. filterEmojis is throttled at 50ms on desktop / 200ms on mobile, and debounced 300ms on native — lodash passes the last args on the trailing call, so the empty term always wins.

No side effects from omitting shouldShowClearButton. Neither emoji picker nor AddAgentRuleSuggestionsTab passes isLoading or rightHandSideComponent, so the spinner and RHS-component branches at lines 570 and 577 are unaffected.

Layout is safe on the compact input. TextInputClearButton's styles.mt4 is overridden by getTextInputIconContainerStyles' marginTop / height: '100%' / justifyContent: 'center', which is why the X sits centered in the 34px listSearchInputWideWrapper field.

Still open from my earlier review (minor): the new unit test doesn't assert the X is hidden while isLoadingNewOptions is true, even though avoiding that is the stated reason for not passing shouldShowClearButton. There's also no test for the two new call sites — acceptable, since they're one-liners, but the emoji picker's uncontrolled→controlled switch is the kind of thing a test would pin down.

Live verification on web (emoji picker, PR head 5f7d1bb)

All four checks passed. No console errors.

Empty field — no X:

Emoji picker open, search field empty, no X button

After typing smi — X appears, field keeps its text, list filters:

Search field showing smi with X button and filtered emoji results

After pressing X — field cleared and the full categorized list (with the Smileys & Emotion header) comes back:

Search field cleared, full categorized list restored

Typing q immediately after pressing X, without clicking the field, landed in the search box — focus was retained:

Typed q without re-clicking field, showing focus was retained

Closing and reopening the picker: field and list both reset together, no desync:

Picker reopened, search field empty and full emoji list shown

Two caveats on the run: the web driver has no raw key-dispatch, so the picker was closed with a click outside rather than Escape, and the accessibility-tree snapshot timed out with the emoji grid open, so the assertions above are from screenshots rather than read-back. Native was not tested.


Reply with @MelvinBot <your feedback> to refine this review.


view run · view recording

@situchan

situchan commented Sep 16, 2026 •

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
  • 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 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 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)
  • 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)
  • 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.
  • 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: mWeb Chrome
iOS: HybridApp
ios.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov

@MelvinBot

MelvinBot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Regression hunt

No functional breakage found. I drove the changed surfaces on web and swept the code for knock-on effects — three behaviour changes are worth a conscious sign-off, none of them a bug.

1. The X adds a new keyboard tab stop on every screen this touches. TextInputClearButton renders a PressableWithoutFeedback, and on web GenericPressable defaults to focusable = true with tabIndex={0}. So once a search field has text, Tab from the input now lands on the X before the list — on ~90 SelectionList screens plus the emoji picker.

The emoji picker is where this deserves a look: its keyboard navigation is hand-rolled, and index.tsx:214 treats Tab as the signal to switch into keyboard-movement mode for the grid. Please tab from the emoji search field into the grid with text typed and confirm nothing gets stuck on the X.

2. The X disappears while a server search is in flight. Confirmed live on Start chat — the green spinner replaces the X, then the X comes back. They're mutually exclusive by construction (line 550 requires !isLoading, line 571 requires !shouldShowClearButton), so there's no overlap — but the right-hand slot now swaps between two icons as you type. It hits the 17 screens that pass isLoadingNewOptions into BaseSelectionList.tsx:291 — New chat, workspace/room invite, task assignee, money-request participants and attendees, add delegate, card assignee, Search user filters. It looked clean in practice, and it matches what SearchAutocompleteInput already does, so this is a design call rather than a defect.

3. Nothing verifies the emoji picker on native or with an IME. index.native.tsx switched that input from uncontrolled to controlled, and Screenshots/Videos still only has MacOS. Separately, there is no composition handling anywhere under src/components/TextInput — making a web input controlled is the classic way to break CJK IME composition. Please type Japanese or Chinese into the emoji picker search on web before merge. I can't drive an IME here, so this is an untested risk, not a found defect.

What I checked and found clean

No rightHandSideComponent collateral. This was my main worry: shouldHideClearButton={!value} also gates the RHS-component branch at line 579, so any consumer passing one would have it vanish as soon as the user typed. SelectionList/components/TextInput.tsx has a closed prop list and never forwards rightHandSideComponent, and neither new call site passes one. No screen is affected.

Only two components render this input — BaseSelectionList.tsx and BaseSelectionListWithSections.tsx — so the blast radius is exactly what the description claims, with no third path.

No layout regression. Typing America/Argentina/Buenos_Aires into the Timezone list kept the full string legible with clear space before the X — no clipping, overlap, or field-height change. TextInputClearButton's styles.mt4 is overridden by getTextInputIconContainerStyles, which is why the X stays centered in the compact 34px field.

Clearing takes the normal path. The button calls setValue('') → onChangeText(''), identical to backspacing, so debounced and server-side search terms reset the same way. Verified on Start chat: field cleared, default list restored, focus retained.

Search fields only. The textInputOptions.label values across the app are all search-shaped (common.search, selectionList.nameEmailOrPhoneNumber, selectionList.findMember) — I found no SelectionList using that input as a data-entry field where a clear button would be out of place. This was a survey, not an exhaustive audit.

One tester observation I'm discounting: setting the field value programmatically (not a real gesture) left the X and a stale "No results found" on screen. That's the automation tool writing the DOM without firing React's onChange, so the value prop stayed non-empty — the X is gated on the prop at line 550. Every real click and keystroke behaved correctly.

Not covered: native (iOS/Android), IME input, and the offline case. CI is green on 5f7d1bb.

Live run on web (PR head 5f7d1bb)

Spinner while the Start chat search is in flight — note the X is gone:

Green loading spinner on the right of the Start chat search field while the search is in flight

Once it settles, the X takes the slot back:

X clear button shown after the search request settles, replacing the spinner

After clicking the X — field cleared, default list back, and text typed immediately afterward landed in the field without re-clicking it:

Start chat field cleared, default list restored, focus retained

Long value in the Timezone list — no clipping against the X:

Timezone search with a long value, text not clipped by the X button

The web driver has no console inspection, so console errors weren't checked directly; all network responses in the run were 2xx.


Reply with @MelvinBot <your feedback> to refine this.


view run · view recording

@jakubstec

Copy link
Copy Markdown
Member Author

Replying to Melvin comment:

  1. The X adds a new keyboard tab stop on every screen this touches. TextInputClearButton renders a PressableWithoutFeedback, and on web GenericPressable defaults to focusable = true with tabIndex={0}. So once a search field has text, Tab from the input now lands on the X before the list — on ~90 SelectionList screens plus the emoji picker.
    The emoji picker is where this deserves a look: its keyboard navigation is hand-rolled, and index.tsx:214 treats Tab as the signal to switch into keyboard-movement mode for the grid. Please tab from the emoji search field into the grid with text typed and confirm nothing gets stuck on the X.

I think it is normal, just like in other places in app.

  1. The X disappears while a server search is in flight. Confirmed live on Start chat — the green spinner replaces the X, then the X comes back. They're mutually exclusive by construction (line 550 requires !isLoading, line 571 requires !shouldShowClearButton), so there's no overlap — but the right-hand slot now swaps between two icons as you type. It hits the 17 screens that pass isLoadingNewOptions into BaseSelectionList.tsx:291 — New chat, workspace/room invite, task assignee, money-request participants and attendees, add delegate, card assignee, Search user filters. It looked clean in practice, and it matches what SearchAutocompleteInput already does, so this is a design call rather than a defect.

I think it's totally normal too.

@jakubstec

Copy link
Copy Markdown
Member Author

@situchan, could you take a look when you have a spare moment? thanks!

@situchan

Copy link
Copy Markdown
Contributor

@jakubstec

Copy link
Copy Markdown
Member Author

What do you think of https://github.com/Expensify/App/pull/101086/changes#r4025635202?

@situchan oh, sorry! I've missed this comment and yeah, you are totally right. fixed that

@melvin-bot
melvin-bot Bot requested a review from mountiny September 18, 2026 17:32
@MelvinBot

MelvinBot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Regression hunt (head d4b71ac)

One likely regression, in the web emoji picker only. The SelectionList side of this PR is clean — I re-drove it and it's a purely additive one-liner.

🔴 Typing after focus is in the emoji grid drops the first character

Repro on this branch: open the emoji picker, type smi, press Tab twice so focus is on an emoji, then type ley. The field ends up at smiey — the leading l is swallowed — and the picker shows "No results found". Reproduced twice, including at 150ms/char to rule out a speed artifact.

Emoji picker search field reads smiey after slow-typing ley with focus in the grid — the leading l was dropped and the list shows No results found

Why this PR is the likely cause. index.tsx:220 calls searchInputRef.current.focus() synchronously inside the document keydown handler, so the character that triggered the handoff is inserted natively by the browser, not by React. On main the input is uncontrolled — defaultValue="" with no value, which makes BaseTextInput pass value={undefined} — so React never writes to the DOM input and that character survives. This PR makes it controlled via value={searchText}, and onFocus fires three setState calls, so React re-renders and writes searchText back into the input — clobbering the natively-inserted character and resetting its value tracker, so no onChange fires.

This is not A/B-confirmed. I brought up an origin/main worktree and dev server, but couldn't navigate the CI-owned browser session onto main's bundle, so the comparison run never happened. Please do the 30-second manual check on main: open the picker, type smi, Tab Tab, type ley. If it reads smiley there, this PR introduced it.

If confirmed, the fix is local — have the keydown handler seed the character it consumed, or keep the handoff path from being clobbered by the controlled write. Web/desktop only: index.native.tsx has no keydown handler, so native isn't affected.

🟢 The resize desync you filmed is gone

The bug you reported is fixed by this PR, as hypothesized in my last review. With smi typed, resizing 1280→1000→900 keeps the field and the filtered list in sync. Crossing the narrow breakpoint (700px) remounts the picker as a bottom sheet and resets field and list together, which is consistent.

After resizing the window the emoji search field still reads smi and the same filtered list is shown — no desync

🟢 The Tab stop I flagged last time is benign

You were right. One Tab lands on the X, a second reaches the grid, and Enter while the X has focus still picks the highlighted emoji — the picker's document-level ENTER shortcut wins. Nothing gets stuck.

One Tab from the emoji search field lands the focus ring on the X clear button

A second Tab moves focus into the emoji grid onto the first result — focus is not trapped on the X

Everything else I checked and found clean

The !value → false simplification is safe. With shouldHideClearButton={false}, line 550 still requires !!value, so the X behaves identically. It does change the rightHandSideComponent branch at line 579 — previously that RHS component rendered while the field was empty; now it never renders. Harmless here: SelectionList/components/TextInput.tsx has a closed prop list that never accepts rightHandSideComponent, and neither the emoji picker nor AddAgentRuleSuggestionsTab passes one. Worth knowing the two forms aren't interchangeable in general, though.

The ~90 SelectionList screens carry no behavioural risk. Against main that file is a single added line — the input was already controlled there, so nothing about how it is driven changed. Contrast with the emoji picker, where the uncontrolled→controlled switch is the actual risk surface.

SelectionList re-verified live (Settings → Profile → Timezone): X appears on Lon, clicking it restores the full list and keeps focus, and re-typing then pressing Enter still selects Europe/London and enables Save.

Timezone SelectionList after clicking the X — field empty and still focused, full list restored

"Find a rule" verified live (Workspace → Rules → Agents → Add AI rule → Suggested). Filtering by receipt cut 41 suggestions to 16 and showed the X; clearing restored all 41 and kept focus.

Find a rule field filtered by receipt with the X clear button visible

Emoji picker clear + reuse is clean. smi → X → full categorized list back, field focused → dog filters correctly → 🐕 inserts into the composer.

Only the focus-on-keypress handoff has this shape. shouldAutoFocusOnKeyPress is used in exactly two places — the emoji picker and ComposerWithSuggestions, which this PR doesn't touch. No SelectionList screen has the equivalent pattern.

Not covered: native (iOS/Android), IME/CJK composition, and offline. The IME risk I raised last review still stands and is untested — making a web input controlled is the classic way to break composition, and there's no composition handling under src/components/TextInput. Console errors weren't read directly; the web driver has no console access, and all network traffic in the run was 200.


Reply with @MelvinBot <your feedback> to refine this.


view run · view recording

@war-in

war-in commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

I verified Melvin's

🔴 Typing after focus is in the emoji grid drops the first character

issue, and it's not reproducible on my end. @mountiny PR's all yours

Screen.Recording.2026-09-21.at.11.11.56.mov

@mountiny mountiny 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.

Seems like even with the added information the comments are missed

expect(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}70`)).toBeSelected();
});

it('should show a clear button once the search field has text and clear the search when it is pressed', () => {

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.

Givne when then

@mountiny
mountiny merged commit 750f49d into Expensify:main Sep 21, 2026
36 of 40 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@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/mountiny in version: 9.4.91-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required for this PR.

This change adds a clear (X) affordance inside search inputs that already existed. It does not add a feature, rename a label or tab, change a setting, or alter any documented workflow — so there is nothing in docs/articles that is now inaccurate.

What I checked

Changed files (d4b71ac):

Docs searched across all of docs/articles:

Per HELP_AUTHORING_GUIDELINES.md, articles document one primary workflow each and must be concise and actionable. Documenting an X icon inside a search box would not meet that bar, so I did not add it anywhere.

Because no changes are needed, I did not create a draft PR, so there is no HelpDot PR to label, assign, or mark ready for review.

@jakubstec, please confirm you agree that no help site update is needed. If you'd still like an article touched — for example to call out the clear button in a specific flow — reply with @MelvinBot and the article and wording you want, and I'll open the draft PR.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.91-3 🚀

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

Bundle Size Analysis (Sentry):

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.

6 participants