[Autocomplete][material-ui] Passing a click handler to the popup indicator #39170
Closed
2 tasks done
Labels
component: autocomplete
This is the name of the generic UI component, not the React module!
support: Stack Overflow
Please ask the community on Stack Overflow
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example:
<Autocomplete
popupIcon={
<IconButton onClick={handlePupupClick} disableRipple disableFocusRipple disableTouchRipple sx={{ py: 0 }}>
<KeyboardArrowDownIcon sx={{ color: theme.palette.primary.main }} />
}
/>
Current behavior 😯
<Autocomplete
popupIcon={
<IconButton onClick={handlePupupClick} disableRipple disableFocusRipple disableTouchRipple sx={{ py: 0 }}>
<KeyboardArrowDownIcon sx={{ color: theme.palette.primary.main }} />
}
/>
If I write like this, can see the following error in the console - Failed prop type: MUI: You are providing an onClick event
listener to a child of a button element. Prefer applying it to the IconButton directly. This guarantees that the whole will be responsive to click events.
If I don't put IconButton and pass onClick directly to KeyboardArrowDownIcon, I can see following error - Warning: validateDOMNesting(...): cannot appear as a descendant of .
Expected behavior 🤔
Expected:
Wrap popup icon in div.
Context 🔦
No response
Your environment 🌎
Google Chrome
The text was updated successfully, but these errors were encountered: