Skip to content

fix: add ...rest props into async autocomplete to customize component#272

Merged
smarcet merged 1 commit into
mainfrom
fix/mui-async-select-spread-props
Jun 23, 2026
Merged

fix: add ...rest props into async autocomplete to customize component#272
smarcet merged 1 commit into
mainfrom
fix/mui-async-select-spread-props

Conversation

@tomrndom

@tomrndom tomrndom commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

  • New Features
    • Async autocomplete component now accepts and forwards additional configuration options, enabling greater flexibility and customization capabilities for developers integrating the component.

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The async Formik autocomplete component now accepts additional incoming props and forwards them to the underlying MUI Autocomplete, while keeping its existing async loading, Formik binding, and default isMulti behavior unchanged.

Changes

Async autocomplete passthrough

Layer / File(s) Summary
Prop passthrough wiring
src/components/mui/formik-inputs/mui-formik-async-select.js
MuiFormikAsyncAutocomplete now captures remaining props in its parameter destructuring and spreads them onto the rendered Autocomplete component.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Poem

🐇 I found two tiny props astray,
and tucked them in along the way.
Through Formik fields they softly hop,
to Autocomplete without a stop.
A neat small nibble for today's crop.

🚥 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 clearly describes the main change: adding rest props spreading to the async autocomplete component for customization, which matches the actual implementation.
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/mui-async-select-spread-props

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/mui/formik-inputs/mui-formik-async-select.js`:
- Line 137: The MuiFormikAsyncSelect component is spreading {...rest} after the
core Autocomplete props, which lets callers override critical handlers and break
Formik/async behavior. Update the MuiFormikAsyncSelect render props so the
{...rest} spread happens before the essential Autocomplete wiring, keeping
onChange, onInputChange, value, options, and renderInput defined by the
component itself. Preserve the existing custom prop passthrough, but ensure the
component’s internal handlers remain the final authoritative props.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2678ead6-3f2e-4a99-a6cc-530bf33177ea

📥 Commits

Reviewing files that changed from the base of the PR and between 789b77e and e72e81a.

📒 Files selected for processing (1)
  • src/components/mui/formik-inputs/mui-formik-async-select.js

{option.label}
</li>
)}
{...rest}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find call sites that may pass colliding props into this wrapper.
rg -n --type-add 'jsx:*.js' --type jsx -C2 \
  '<MuiFormikAsyncAutocomplete[^>]*(onChange|onInputChange|value|options|renderInput|getOptionLabel|isOptionEqualToValue)\s*=' src

# Confirm current prop ordering in the wrapper component.
sed -n '90,150p' src/components/mui/formik-inputs/mui-formik-async-select.js

Repository: OpenStackweb/openstack-uicore-foundation

Length of output: 178


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the file with flexible search
fd -i "mui-formik-async-select" . --type f

# Also search for variations
fd -i "async.*select" src --type f 2>/dev/null | head -20

Repository: OpenStackweb/openstack-uicore-foundation

Length of output: 424


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the component file to see prop ordering
cat -n src/components/mui/formik-inputs/mui-formik-async-select.js

# Then search for actual usages
echo "=== Searching for MuiFormikAsyncAutocomplete usage ==="
rg -n "MuiFormikAsyncAutocomplete" src --type js --type jsx

Repository: OpenStackweb/openstack-uicore-foundation

Length of output: 5301


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for usage of MuiFormikAsyncAutocomplete without type specification
rg -n "MuiFormikAsyncAutocomplete" src --type-list | head -20

# Try simple grep
grep -rn "MuiFormikAsyncAutocomplete" src 2>/dev/null | head -30

Repository: OpenStackweb/openstack-uicore-foundation

Length of output: 568


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for usage of MuiFormikAsyncAutocomplete
grep -rn "MuiFormikAsyncAutocomplete" src --include="*.js" --include="*.jsx" 2>/dev/null | grep -v "node_modules"

Repository: OpenStackweb/openstack-uicore-foundation

Length of output: 846


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the test file to see how MuiFormikAsyncAutocomplete is being used
cat -n src/components/mui/__tests__/mui-formik-async-select.test.js

Repository: OpenStackweb/openstack-uicore-foundation

Length of output: 3899


Move {...rest} before core Autocomplete props to prevent overrides of critical handlers.

Spreading {...rest} last at line 137 allows callers to override onChange, onInputChange, value, options, and renderInput, which would break Formik state updates and async fetch behavior. Move the spread operator before these critical props so custom properties merge without shadowing essential wiring.

Suggested fix
   return (
     <Autocomplete
+      {...rest}
       options={options}
       value={value}
       onChange={handleChange}
       loading={loading}
       multiple={isMulti}
       fullWidth
       getOptionLabel={(option) => option.label || ""}
       isOptionEqualToValue={(option, value) => option.value === value.value}
       onInputChange={(e, newInput) => setSearchTerm(newInput)}
       renderInput={(params) => (
         <TextField
           {...params}
           placeholder={placeholder}
           variant="outlined"
           error={Boolean(error)}
           helperText={error || ""}
           slotProps={{
             input: {
               ...params.InputProps,
               endAdornment: (
                 <>
                   {loading && <CircularProgress color="inherit" size={20} />}
                   {params.InputProps?.endAdornment}
                 </>
               )
             },
             inputLabel: { shrink: false }
           }}
           sx={{
             "& input::placeholder": {
               color: "`#00000061`",
               opacity: 1
             }
           }}
         />
       )}
       renderOption={(props, option, { selected }) => (
         <li {...props}>
           {multiple && <Checkbox checked={selected} sx={{ mr: 1 }} />}
           {option.label}
         </li>
       )}
-      {...rest}
     />
   );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{...rest}
return (
<Autocomplete
{...rest}
options={options}
value={value}
onChange={handleChange}
loading={loading}
multiple={isMulti}
fullWidth
getOptionLabel={(option) => option.label || ""}
isOptionEqualToValue={(option, value) => option.value === value.value}
onInputChange={(e, newInput) => setSearchTerm(newInput)}
renderInput={(params) => (
<TextField
{...params}
placeholder={placeholder}
variant="outlined"
error={Boolean(error)}
helperText={error || ""}
slotProps={{
input: {
...params.InputProps,
endAdornment: (
<>
{loading && <CircularProgress color="inherit" size={20} />}
{params.InputProps?.endAdornment}
</>
)
},
inputLabel: { shrink: false }
}}
sx={{
"& input::placeholder": {
color: "`#00000061`",
opacity: 1
}
}}
/>
)}
renderOption={(props, option, { selected }) => (
<li {...props}>
{multiple && <Checkbox checked={selected} sx={{ mr: 1 }} />}
{option.label}
</li>
)}
/>
);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/formik-inputs/mui-formik-async-select.js` at line 137, The
MuiFormikAsyncSelect component is spreading {...rest} after the core
Autocomplete props, which lets callers override critical handlers and break
Formik/async behavior. Update the MuiFormikAsyncSelect render props so the
{...rest} spread happens before the essential Autocomplete wiring, keeping
onChange, onInputChange, value, options, and renderInput defined by the
component itself. Preserve the existing custom prop passthrough, but ensure the
component’s internal handlers remain the final authoritative props.

@tomrndom tomrndom requested a review from smarcet June 23, 2026 14:40

@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 bdf41a0 into main Jun 23, 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