-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[question] How to theme the singleSelect options dropdown #4305
Comments
I can't use the native element and icons at the same time or am I wrong? In my use case I got e.g. a column called status and via Inside of the single select filter for that status column I only got the status text, so there is no reference between the grid cell status icon and the filter status select option. I would expect that there is a callback to format the filter values like we have for cells ( |
Yes, when singlSelect will support non-native Select having a |
@alexfauquette Thanks for the update. I'll check it out after a new version is released. |
The latest release includes #4361. But you still can't provide custom options because the option component is hardcoded to be |
@m4theushw Thanks for the update. I updated to 5.10.0 and I got the following behavior: My filterOperator InputComponent return this Select component: <Select
id={item.columnField}
label={apiRef.current.getLocaleText('filterPanelInputLabel')}
placeholder={apiRef.current.getLocaleText('filterPanelInputPlaceholder')}
value={item.value}
onChange={handleFilterChange}
variant="standard"
inputRef={focusElementRef}
>
{renderSingleSelectOptions(apiRef.current.getColumn(item.columnField), apiRef.current)}
</Select> and the renderSingleSelectOptions callback: const renderSingleSelectOptions = (currentColum, api) => {
const { valueOptions, valueFormatter, field } = currentColum;
return valueOptions.map(option =>
<MenuItem value={option} key={option}>
<ListItemIcon>
{renderDeviceStatusIcon(option)}
</ListItemIcon>
<ListItemText>
{valueFormatter({ value: option, field, api })}
</ListItemText>
</MenuItem>);
}; Should that already work or am I missing something? |
Without a full reproduction, it is hard to tell https://codesandbox.io/s/custominputcomponent-material-demo-forked-3yl4dh?file=/demo.js |
@alexfauquette Thanks for investing the time to update the codesandbox! I also did add some CSS to fix the filter panel styles and updated the codesandbox in case somebody is also looking for a solution: I still got an issue that there is no default On the whole the effort to theme the filter value is IMO too complicated compared to what a user tries to accomplish. |
There is not empty option because you did not set them The default input for singleSelect filter add an empty string before the value options This in line 24 of your codeSandbox should fix it -return valueOptions.map((option) => (
+return ["", ...valueOptions].map((option) => ( https://codesandbox.io/s/custominputcomponent-material-demo-forked-r131k8?file=/demo.js |
Somehow I thought the empty option is set way earlier. And I needed to add I updated the codesandbox one more time with the complete solution https://codesandbox.io/s/custominputcomponent-material-demo-forked-jse81u?file=/demo.js |
Order ID 💳
35878
Duplicates
Latest version
The problem in depth 🔍
I try to theme the singleSelect option dropdown. My goal is to add an icon in front of all menu items. Therefore I did fork the CustomInputComponent example from the docs and replaced the Rating component with a Select component.
My problem currently is that the dropdown menu items are not selectable (handleFilterChange is not triggered at all) and that the dropdown does close right after clicking on it. The reason is probably that inputRef is not set correctly, but I'm totally stuck at that point. Any help would be greatly appreciated.
I created a codesandbox with the current state of my work:
https://codesandbox.io/s/custominputcomponent-material-demo-forked-w8l935?file=/demo.js:1454-1462
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: