Comments (3)
This looks like a duplicate of another support question we had on the autocomplete.
from material-ui.
in inputProps of TextField component (<TextField {...params} inputProps={{ "aria-label": "foo" }} />)
@KingWarin This should work! Here's a demo: https://stackblitz.com/edit/mcve-react-material-ui-npgl9s?file=src%2FApp.tsx
// https://github.com/mui/material-ui/issues/42627
import * as React from 'react';
import { Autocomplete, TextField } from '@mui/material';
export default function Playground() {
return (
<Autocomplete
disablePortal
options={OPTIONS}
sx={{ width: 300 }}
renderInput={(params) => (
<TextField
{...params}
inputProps={{
...params.inputProps,
'aria-label': 'foo',
}}
/>
)}
/>
);
}
const OPTIONS = [
{ label: 'Forrest Gump', year: 1994 },
{ label: 'Inception', year: 2010 },
{
label: 'The Lord of the Rings: The Two Towers',
year: 2002,
},
];
it is correctly set on the but the whole component breaks and produces an error when it is focused
I can't reproduce this, see the demo above!
By the way, I also noticed that in some places in your sandbox inputProps
is incorrectly nested inside InputProps
:
<Autocomplete
renderInput={(params) => (
<TextField
{...params}
InputProps={{
inputProps: {
...params.inputProps,
"aria-label": "foo",
},
}}
/>
)}
/>
from material-ui.
@mj12albert the nesting of inputProps
inside InputProps
was me trying all possible combinations I (with the help of intellisense) could think of...
Just took a look at your demo. In trying to find a valid combination I didn't add the ...params.inputProps
inside the inputProps
(as seen in the commented component of my codesandbox) which in led to having the aria-label on the resulting input, but everything else breaking, as the default functions where missing.
So you're absolutely right and after adding the spread it works.
Thank you very much for the reply.
from material-ui.
Related Issues (20)
- [Select] Render options below Select's DOM position instead of in a portal HOT 2
- [RFC] Restructure icons exports HOT 2
- [SKELETON] [BUG] Skeleton Height is Unpredictable(Ghost Padding or Margin) Without `variant` Attribute HOT 1
- npm install @mui/styles ERROR HOT 4
- [joy-ui] Temperature check on the future of Joy UI
- [docs-infra] CodeSandbox/StackBlitz broken for demos with relative imports
- test #42499 HOT 1
- [docs] Random Unsplash photo URL is no longer functional HOT 2
- [docs] Add documentation for preventing SSR flicker/FOUC with the Next.js app router HOT 3
- sx prop not work HOT 1
- [v6] Module not found: DefaultPropsProvider/ InitColorSchemeScript HOT 8
- [joy-ui] When using styled('div') all its properties are lost
- bug: Preact example is throwing errors HOT 2
- [mui autocomplete] : label cut off when the option list is displayed above.
- @mui/material: incorrect responsiveFontSizes return type when using CssVarsTheme as input HOT 2
- [RFC][Grid v2] Stabilize API HOT 4
- [docs][Grid v2] Restructure docs HOT 2
- Some bad ts performance cases
- Mui input base text area style is not applied correctly with input props on 5.15.11 from 5.15.10 HOT 2
- [Joy UI] Typography color is not defined by what is on the table
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-ui.