Skip to content

fix(UserSearchField): restore type-ahead broken by MUI v9 slotProps migration#1608

Merged
yi-nuo426 merged 2 commits into
masterfrom
claude/dazzling-carson-aFtUX
Jun 3, 2026
Merged

fix(UserSearchField): restore type-ahead broken by MUI v9 slotProps migration#1608
yi-nuo426 merged 2 commits into
masterfrom
claude/dazzling-carson-aFtUX

Conversation

@leecalcote
Copy link
Copy Markdown
Member

Problem

Every user/team picker that offers a type-ahead — Add User, Add Team Member, the share-modal people picker, and the dashboard team picker — stopped suggesting as you type. The input still accepted text, but no search fired and the suggestion list never opened.

Root cause

The MUI v9 slotProps migration (b81e4dc) rewrote each picker's renderInput to hand the TextField an explicit slotProps object:

<TextField
  {...params}
  slotProps={{ input: { ...params.slotProps?.input, endAdornment } }}
/>

In MUI v9, the Autocomplete's renderInput params expose the native <input> wiring under params.slotProps.htmlInput (the value/onChange/onKeyDown/focus handlers and the anchor ref from getInputProps()), alongside the input and inputLabel slots.

A second slotProps prop replaces — it does not merge with — the slotProps spread by {...params}. Because the explicit object only set input (and sometimes inputLabel), params.slotProps.htmlInput was dropped. TextField sources the native input props solely from that slot (inputProps: htmlInputPropsslotProps.htmlInput), so the field rendered a bare <input> with none of the Autocomplete's wiring: keystrokes never reached onInputChange, the query never ran, and the listbox never opened.

Fix

Spread ...params.slotProps into the explicit object so htmlInput survives, and merge (rather than replace) the input/inputLabel slots:

slotProps={{
  ...params.slotProps,
  inputLabel: { ...params.slotProps?.inputLabel, style: { fontFamily: 'inherit' } },
  input: { ...params.slotProps?.input, endAdornment },
}}

Applied to all four affected pickers:

  • UserSearchField — Add User / Add Team Member
  • UserShareSearch — share-modal people picker
  • TeamSearchField — dashboard getting-started widget
  • InputSearchField — generic search field

Test plan

  • New UserSearchFieldInput.test.tsx — types into the picker and asserts the search callback fires with the typed value and the matching user renders in the suggestion list. Verified both assertions fail on the pre-fix code and pass after.
  • Full suite: 13 suites / 299 tests green.
  • npm run build (incl. DTS typecheck), eslint, and prettier --check all clean.

Downstream

@sistent/sistent consumers (e.g. meshery-cloud, currently on ^0.21.18) pick this up on the next published release + dependency bump.

…tmlInput slot

The MUI v9 slotProps migration handed each picker's renderInput TextField an
explicit `slotProps` object that only set the `input` (and `inputLabel`) slot.
An explicit `slotProps` prop replaces the one spread from `{...params}`, so this
dropped `params.slotProps.htmlInput` — the native <input> wiring (value,
onChange, keydown/focus handlers and the anchor ref from getInputProps). The
input was silently disconnected from the Autocomplete: keystrokes never reached
onInputChange, the search never fired and the suggestion list never opened.

Spread `...params.slotProps` into the explicit object so htmlInput survives, and
merge (instead of replace) the input/inputLabel slots. Restores the type-ahead
across UserSearchField (Add User / Add Team Member), UserShareSearch (share
modal picker), TeamSearchField and InputSearchField.

Add a regression test that types into the picker and asserts the search callback
fires and the matching option renders.

Signed-off-by: Lee Calcote <leecalcote@gmail.com>
Copilot AI review requested due to automatic review settings June 3, 2026 17:40
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates several search field components to correctly spread params.slotProps into their underlying inputs, ensuring compatibility with MUI's controlled Autocomplete behavior. It also adds a regression test suite for UserSearchFieldInput to verify type-ahead functionality. The review feedback points out that overwriting endAdornment in UserSearchField discards default MUI adornments (like the dropdown arrow and clear button) and suggests merging them instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/custom/UserSearchField/UserSearchField.tsx
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request restores MUI Autocomplete type-ahead behavior across several picker/search components by ensuring params.slotProps (including the critical htmlInput wiring) is preserved when passing an explicit slotProps object to TextField. It also adds a regression test to catch future regressions of this MUI v9 slotProps merge behavior.

Changes:

  • Preserve Autocomplete input wiring by spreading ...params.slotProps and merging input / inputLabel slot overrides instead of replacing the whole object.
  • Apply the slotProps merge fix to User, Share-modal user picker, Team picker, and generic InputSearchField.
  • Add a regression test asserting keystrokes trigger the search callback and that matching suggestions render.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/custom/UserSearchField/UserSearchFieldInput.tsx Fixes TextField slotProps merging so Autocomplete htmlInput wiring isn’t dropped.
src/custom/UserSearchField/UserSearchFieldInput.test.tsx Adds regression coverage for the restored type-ahead wiring (keystrokes + suggestions).
src/custom/UserSearchField/UserSearchField.tsx Preserves Autocomplete wiring by spreading params.slotProps in the share-modal picker.
src/custom/InputSearchField/InputSearchField.tsx Preserves Autocomplete wiring by spreading params.slotProps in the generic search field.
src/custom/DashboardWidgets/GettingStartedWidget/TeamSearchField.tsx Preserves Autocomplete wiring by spreading params.slotProps in the team picker.

Comment thread src/__testing__/UserSearchFieldInput.test.tsx
Comment thread src/custom/UserSearchField/UserSearchFieldInput.test.tsx Outdated
Move the picker type-ahead regression test to src/__testing__ to match the
repository's established test layout, and type its props via
React.ComponentProps<typeof UserSearchField> instead of an `any` cast,
selecting the input through Testing Library's combobox role.

Signed-off-by: Lee Calcote <leecalcote@gmail.com>
@yi-nuo426 yi-nuo426 merged commit 66376ab into master Jun 3, 2026
5 checks passed
@yi-nuo426 yi-nuo426 deleted the claude/dazzling-carson-aFtUX branch June 3, 2026 20:09
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.

4 participants