fix: Show "Search for X" option when reopening UserSearch with text#262
Open
Amund211 wants to merge 2 commits into
Open
fix: Show "Search for X" option when reopening UserSearch with text#262Amund211 wants to merge 2 commits into
Amund211 wants to merge 2 commits into
Conversation
MUI's Autocomplete passes `inputValue: ''` to `filterOptions` when the popup reopens with the input value matching the previously selected option's label. That suppressed the free-text "Search for X" entry until the user typed a character to flip the pristine flag. Control `inputValue` ourselves and forward it to `filterOptions` so the free-text option is always shown when there's text in the input. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Asserts that the "Search for X" option appears when the search popup is reopened after a previous selection has filled the input with that option's label. Without the fix in the preceding commit, MUI's empty-string trick passes inputValue: '' to filterOptions on reopen and suppresses the free-text branch until the user edits the input. Verified the test fails on HEAD~1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Deploying rainbow with
|
| Latest commit: |
50d030f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7bd19cd7.rainbow-ctx.pages.dev |
| Branch Preview URL: | https://fix-user-search-freetext-on.rainbow-ctx.pages.dev |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a MUI Autocomplete edge case where the UserSearch free-text “Search for X” option disappears when reopening the popup while the input still contains the previously selected option’s label (common on /session/$uuid where the component stays mounted across navigation).
Changes:
- Controls
Autocomplete’sinputValueinUserSearchand forwards that value intofilterOptionsto avoid MUI’s reopen-time empty-stringinputValuebehavior. - Adds a UI regression test on the session detail route to ensure the free-text option is still shown after reopening with previously selected text.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/components/UserSearch.tsx |
Controls inputValue and ensures filterOptions receives the real input text when reopening. |
src/routes/session/-uuid.ui.test.tsx |
Adds a UI test reproducing the reopen regression and asserting the free-text option is present. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+304
to
311
| <Autocomplete<SearchOption, false, true> | ||
| options={uuids.map((uuid) => ({ type: "uuid" as const, uuid }))} | ||
| fullWidth | ||
| size={size} | ||
| // TODO: Clear the input when the user selects an option | ||
| blurOnSelect | ||
| selectOnFocus | ||
| autoHighlight |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/session/$uuidwhere the component stays mounted across selection.useAutocompletepassesinputValue: ''tofilterOptionswheninputValueIsSelectedValue && inputPristine(single-select, the input still holds the previously selected option's label, and the popup just reopened). That zeros out theinputValue.trim() ? [...] : []branch in ourfilterOptions.inputValueourselves and forward it tofilterOptions, bypassing the empty-string trick./session/$uuidthat reproduces the bug; verified it fails on the parent commit.Test plan
pnpm tscpnpm lint:checkpnpm test:ui:chromium— all 197 tests pass🤖 Generated with Claude Code