Skip to content

fix(company-input-v2): commit typed/autofilled value on blur#241

Open
gcutrini wants to merge 1 commit into
mainfrom
fix/company-input-autofill-commit
Open

fix(company-input-v2): commit typed/autofilled value on blur#241
gcutrini wants to merge 1 commit into
mainfrom
fix/company-input-autofill-commit

Conversation

@gcutrini
Copy link
Copy Markdown
Contributor

@gcutrini gcutrini commented May 15, 2026

ref: https://app.clickup.com/t/86b9rnr4r

Summary

CompanyInputV2 wraps MUI Autocomplete in freeSolo mode, but onChange only fires when the user explicitly selects an option. Values entered via typing-and-tabbing or browser autofill (notably iOS Chrome) never propagate to the parent, so required-field validation fails on submit.

Reproduce with autofill simulation in DevTools: set the input value via the native setter, dispatch input, then blur — without this PR the parent's company stays {id: null, name: ""}; with it the parent receives {id: 0, name: <typed>}.

Changes

  • Add autoSelect to the Autocomplete. MUI's intended mechanism for committing the current input value on blur in a free-text combo.
  • Normalize strings in onChange to the {id, name} shape consumers expect, since autoSelect calls onChange with the raw typed/autofilled string.

Summary by CodeRabbit

  • Bug Fixes
    • Improved company input field to properly normalize manually typed values, including automatic whitespace trimming and consistent formatting when input changes occur.

Review Change Stack

MUI Autocomplete in freeSolo mode only fires onChange when the user
explicitly selects an option, so values entered via typing-and-tabbing
or browser autofill (notably iOS Chrome) never propagate to the parent
and required-field validation fails on submit.

- Enable Autocomplete autoSelect so the current input value is committed
  on blur, matching MUI's intended pattern for free-text combos.
- Normalize string values inside onChange to the {id, name} shape that
  consumers expect, since autoSelect emits the raw typed string.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 498003a2-926b-4342-b4de-8655813e88b4

📥 Commits

Reviewing files that changed from the base of the PR and between e01d8de and c5935fb.

📒 Files selected for processing (1)
  • src/components/inputs/company-input-v2.js

📝 Walkthrough

Walkthrough

CompanyInputV2 now enables autoSelect on the Autocomplete component and normalizes raw typed strings by trimming and converting them into { id: 0, name: <trimmed> } objects for consistent downstream processing before the change event is emitted.

Changes

Company Input String Normalization

Layer / File(s) Summary
String-to-object normalization on company input change
src/components/inputs/company-input-v2.js
Autocomplete is configured with autoSelect. When a raw typed string is entered, the onChange handler trims it and converts it into a { id: 0, name } object for consistent downstream handling before emitting the change event.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐇 A company name typed with care,
Now trimmed and shaped as a proper pair,
With id: 0 and name so clean,
The finest normalization I've seen!
Auto-select brings harmony true,
A simple fix, yet it makes things new. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: adding blur event handling to commit typed/autofilled values in CompanyInputV2. It directly reflects the main fix introduced in this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/company-input-autofill-commit

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gcutrini gcutrini requested a review from smarcet May 15, 2026 23:25
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.

1 participant