Skip to content

Commit

Permalink
Use matching icon colors in Select controls
Browse files Browse the repository at this point in the history
This ensures that (in light mode) if a Select controls component renders
an icon for the current value (and for the MenuSelectTextAlign, for the
options too), it matches the color of the non-selected MenuButton
controls and the color of the select dropdown arrow.
  • Loading branch information
sjdemartini committed Aug 17, 2023
1 parent 0f466fb commit ddb43ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/controls/MenuSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ const useStyles = makeStyles({ name: { MenuSelect } })((theme) => {
"&:not(:hover):not(.Mui-focused) .MuiOutlinedInput-notchedOutline": {
borderWidth: 0,
},

"& .MuiSvgIcon-root": {
// Ensure that if an icon is used as the `renderValue` result, it uses
// the same color as the default ToggleButton icon and the Select
// dropdown arrow icon
// https://github.com/mui/material-ui/blob/2cb9664b16d5a862a3796add7c8e3b088b47acb5/packages/mui-material/src/ToggleButton/ToggleButton.js#L60,
// https://github.com/mui/material-ui/blob/0b7beb93c9015da6e35c2a31510f679126cf0de1/packages/mui-material/src/NativeSelect/NativeSelectInput.js#L96,
color: theme.palette.action.active,
},
},

select: {
Expand Down
9 changes: 7 additions & 2 deletions src/controls/MenuSelectTextAlign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface MenuSelectTextAlignProps
emptyLabel?: React.ReactNode;
}

const useStyles = makeStyles({ name: { MenuSelectTextAlign } })({
const useStyles = makeStyles({ name: { MenuSelectTextAlign } })((theme) => ({
selectInput: {
// We use a fixed width equal to the size of the menu button icon so that
// the Select element won't change sizes even if we show the "blank"
Expand All @@ -101,8 +101,13 @@ const useStyles = makeStyles({ name: { MenuSelectTextAlign } })({

menuButtonIcon: {
fontSize: MENU_BUTTON_FONT_SIZE_DEFAULT,
// For consistency with toggle button default icon color and the Select
// dropdown arrow icon color
// https://github.com/mui/material-ui/blob/2cb9664b16d5a862a3796add7c8e3b088b47acb5/packages/mui-material/src/ToggleButton/ToggleButton.js#L60,
// https://github.com/mui/material-ui/blob/0b7beb93c9015da6e35c2a31510f679126cf0de1/packages/mui-material/src/NativeSelect/NativeSelectInput.js#L96
color: theme.palette.action.active,
},
});
}));

const DEFAULT_ALIGNMENT_OPTIONS: TextAlignSelectOption[] = [
{
Expand Down

0 comments on commit ddb43ab

Please sign in to comment.