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

fix(odyssey-react-mui): make Autocomplete option styles match Select #1935

Merged
merged 4 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/odyssey-react-mui/src/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ const Autocomplete = <
<MuiAutocomplete
// AutoComplete is wrapped in a div within MUI which does not get the disabled attr. So this aria-disabled gets set in the div
aria-disabled={isDisabled}
disableCloseOnSelect={hasMultipleChoices}
disabled={isDisabled}
freeSolo={isCustomValueAllowed}
loading={isLoading}
Expand Down
38 changes: 34 additions & 4 deletions packages/odyssey-react-mui/src/theme/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { ThemeOptions } from "@mui/material";
import type {} from "@mui/lab/themeAugmentation";
import { alertTitleClasses } from "@mui/material/AlertTitle";
import { autocompleteClasses } from "@mui/material/Autocomplete";
import { buttonClasses } from "@mui/material/Button";
import { checkboxClasses } from "@mui/material/Checkbox";
import { chipClasses } from "@mui/material/Chip";
Expand Down Expand Up @@ -269,15 +270,39 @@ export const components = (
paddingBlock: odysseyTokens.Spacing2,
paddingInline: odysseyTokens.Spacing2,
borderRadius: odysseyTokens.BorderRadiusMain,

[`& .${autocompleteClasses.option}`]: {
minHeight: "unset",
paddingBlock: odysseyTokens.Spacing3,
paddingInline: odysseyTokens.Spacing4,
borderRadius: odysseyTokens.BorderRadiusTight,

[`&:hover`]: {
backgroundColor: odysseyTokens.HueNeutral100,
},

[`&.${autocompleteClasses.focused}`]: {
backgroundColor: odysseyTokens.HueNeutral100,
},

[`&[aria-selected="true"]`]: {
backgroundColor: "transparent",
color: odysseyTokens.TypographyColorAction,

[`&:hover`]: {
backgroundColor: odysseyTokens.PalettePrimaryLighter,
},

[`&.${autocompleteClasses.focused}`]: {
backgroundColor: odysseyTokens.PalettePrimaryLighter,
},
},
},
},
loading: {
paddingBlock: odysseyTokens.Spacing3,
paddingInline: odysseyTokens.Spacing4,
},
option: {
paddingBlock: odysseyTokens.Spacing3,
borderRadius: odysseyTokens.BorderRadiusTight,
},
popupIndicator: {
padding: odysseyTokens.Spacing1,
marginRight: "unset",
Expand Down Expand Up @@ -1598,6 +1623,7 @@ export const components = (
gap: odysseyTokens.Spacing2,
minHeight: "unset",
paddingBlock: odysseyTokens.Spacing3,
paddingInline: odysseyTokens.Spacing4,
borderRadius: odysseyTokens.BorderRadiusTight,

[`& .${formControlLabelClasses.root}`]: {
Expand All @@ -1614,6 +1640,10 @@ export const components = (
},
},

[`:focus-visible`]: {
backgroundColor: odysseyTokens.HueNeutral100,
},

[`&.${menuItemClasses.root}-destructive`]: {
color: odysseyTokens.TypographyColorDanger,
},
Expand Down
Loading