Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui][Autocomplete] freeSolo type search not allowed to change/edit the clearIcon #42995

Closed
indrasenakatam opened this issue Jul 19, 2024 · 2 comments
Labels
component: autocomplete This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material support: Stack Overflow Please ask the community on Stack Overflow

Comments

@indrasenakatam
Copy link

indrasenakatam commented Jul 19, 2024

Steps to reproduce

Link to live example: (required)

There is no specific steps, I have copied code from docs, from https://mui.com/material-ui/react-autocomplete/#free-solo

Steps:

  1. Import Autocomplete
  2. override default clear icon
  3. Have tried with auto complete property https://mui.com/material-ui/api/autocomplete/#autocomplete-prop-clearIcon

`
import Autocomplete from '@mui/material/Autocomplete';
import DeleteIcon from '@mui/icons-material/Delete';

<Autocomplete
freeSolo
id="free-solo-2-demo"
disableClearable
options={top100Films.map((option) => option.title)}
clearIcon={<DeleteIcon></DeleteIcon>}
renderInput={(params) => (
<TextField
{...params}
label="Search input"
InputProps={{
...params.InputProps,
type: 'search',
}}
/>
)}
/>`

Current behavior

image

Expected behavior

I would like to replace existing default clearIcon with my own SVG Ion

Context

No response

Your environment

"use client";

import * as React from "react";
import TextField from "@mui/material/TextField";
import Stack from "@mui/material/Stack";
import Autocomplete from "@mui/material/Autocomplete";
import DeleteIcon from "@mui/icons-material/Delete";

export default function FreeSolo() {
return (
<Stack spacing={2} sx={{ width: 300 }}>
<Autocomplete
freeSolo
id="free-solo-2-demo"
disableClearable
options={top100Films.map((option) => option.title)}
clearIcon={}
renderInput={(params) => (
<TextField
{...params}
label="Search input"
InputProps={{
...params.InputProps,
type: "search",
}}
/>
)}
/>

);
}

   "@mui/base": "5.0.0-beta.40",
    "@mui/icons-material": "^5.16.4",
    "@mui/material": "^5.16.4",
    "@mui/system": "^5.16.4",
    
    NEXT js:   "next": "15.0.0-canary.56",
    
    "node": ">=20.12.0"
    
    Google Chrome: Version 126.0.6478.127 

Search keywords: Autocomplete freeSolo type search

@indrasenakatam indrasenakatam added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 19, 2024
@zannager zannager added the component: autocomplete This is the name of the generic UI component, not the React module! label Jul 19, 2024
@zanivan zanivan changed the title Autocomplete freeSolo type search not allowed to change/edit the clearIcon [material-ui][Autocomplete] freeSolo type search not allowed to change/edit the clearIcon Jul 25, 2024
@ZeeshanTamboli
Copy link
Member

It works. See: https://stackblitz.com/edit/vitejs-vite-nu9jpl?file=src%2FApp.tsx&terminal=dev.

The disableClearable prop in the Autocomplete prevents the clear icon from rendering by disabling the clear functionality. Additionally, setting type="search" on the input renders the native clear icon.

@ZeeshanTamboli ZeeshanTamboli added support: Stack Overflow Please ask the community on Stack Overflow package: material-ui Specific to @mui/material and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 30, 2024
Copy link

👋 Thanks for using our open-source projects!

We use GitHub issues exclusively as a bug and feature requests tracker, however,
this issue appears to be a support request.

For support with Material UI please check out https://mui.com/material-ui/getting-started/support/. Thanks!

If you have a question on Stack Overflow, you are welcome to link to it here, it might help others.
If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material support: Stack Overflow Please ask the community on Stack Overflow
Projects
None yet
Development

No branches or pull requests

4 participants