Skip to content

fix(company-input-v2): explicit selection, no clear icon, Use "<typed>" row (v4 backport) - #290

Merged
smarcet merged 1 commit into
v4.xfrom
feature/company-input-v2-freetext-use-option-v4
Jul 14, 2026
Merged

fix(company-input-v2): explicit selection, no clear icon, Use "<typed>" row (v4 backport)#290
smarcet merged 1 commit into
v4.xfrom
feature/company-input-v2-freetext-use-option-v4

Conversation

@gcutrini

Copy link
Copy Markdown
Contributor

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

Backport of #289 to the v4.x line.

The bug

CompanyInputV2 used MUI's autoSelect, which commits the currently highlighted option on blur. Users would mouse over a suggestion, then tab away intending to keep their typed text — and the moused-over company got saved instead (wrong company populated).

Changes (src/components/inputs/company-input-v2.js)

  • Remove autoSelect — selection is now explicit (click / Enter) only. This is the root-cause fix.
  • New onBlur — tab/click-away commits exactly what was typed: resolved to an existing company only on an exact (case-insensitive) name match, otherwise a free-text { id: 0, name }. Never commits a merely-highlighted option. Reads the DOM value (event.target.value) so browser autofill (notably Chrome iOS) is captured even when React input state is stale — preserves the fix from fix(company-input-v2): commit typed/autofilled value on blur #241.
  • disableClearable — removes the MUI clear (x) icon (the field commits free text, so an explicit clear affordance isn't wanted; delete the text to empty).
  • Use "<typed>" rowfilterOptions prepends a synthetic option so users can explicitly commit their typed text; skipped when it already matches a listed company. Commits a clean { id: 0, name } (display-only marker stripped).

⚠️ Shared-component behavior change

This affects all CompanyInputV2 consumers, not just the requesting screen: no more clear (x) icon, and blur no longer auto-selects a highlighted option (it keeps the typed text). Both are intentional — flagging for reviewers.

Tests

28/28 green on the file's suite. Coverage includes: hover-then-tab guard, Chrome iOS autofill DOM-value path, empty-blur clear, disableClearable, Use "…" row commit + hidden on exact match, canonical-case resolution on blur.

…main (v4.x)

Port of PR #289 + layered commits from main:
- Remove `autoSelect` (root cause of hover-then-tab wrong-company commits)
- Explicit onBlur that reads event.target.value (DOM value; falls back to
  React input state) so browser autofill still propagates on blur --
  preserves #241/#246's iOS Chrome autofill fix
- `disableClearable`: with free-text supported, an explicit clear (x)
  isn't wanted; users empty by deleting the text
- Synthetic "Use "<typed>"" row prepended to dropdown when the typed text
  isn't already listed; committed cleanly (marker stripped) via onChange
- Extract `getOptionName` helper used by getOptionLabel, filterOptions,
  renderOption; rename local `label` in renderOption to `displayLabel`
  to stop shadowing the outer prop

Tests: +7 (28/28 green), including regression coverage for the hover-then-tab
guard, the DOM-value autofill path, and the Use/free-text commits.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2e8e670e-740e-4cba-857d-7d3c7feeecec

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/company-input-v2-freetext-use-option-v4

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.

@gcutrini
gcutrini requested a review from smarcet July 14, 2026 17:50

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@smarcet
smarcet merged commit bea854e into v4.x Jul 14, 2026
5 checks passed
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.

2 participants