Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Pass through className on option element as child of select (#381)
Browse files Browse the repository at this point in the history
* pass classnames passed to the option element in a select's child array of options

* pass through child classname for each option

* don't pass classnames to popper
  • Loading branch information
mayakoneval authored Nov 4, 2021
1 parent 5b97e5d commit abe14c8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ interface ListItemWrapperProps
/** Passthrough downshift function to get the props for an item */
getItemProps: UseSelectPropGetters<OptionProps>["getItemProps"];
selected: boolean;
className?: string;
}

/**
Expand All @@ -92,6 +93,7 @@ const ListItemWrapper: React.FC<ListItemWrapperProps> = ({
renderListItem,
selected,
selectionIndicator,
className,
}) => {
const index = downshiftItems.indexOf(element.props);

Expand All @@ -109,10 +111,10 @@ const ListItemWrapper: React.FC<ListItemWrapperProps> = ({

return (
<ClassNames>
{({ css }) => {
{({ css, cx }) => {
return renderListItem(
{
className: css({ alignItems: "baseline" }),
className: cx(css({ alignItems: "baseline" }), className),
key: element.props.value || element.props.children,
...downshiftItemProps,
highlighted: downshiftItemProps["aria-selected"] === "true",
Expand Down Expand Up @@ -490,6 +492,7 @@ export const Select: React.FC<Props> = ({
if (isHTMLOptionElement(child)) {
return (
<ListItemWrapper
className={child.props.className}
data-top-level-index={topLevelIndex}
downshiftItems={items}
element={child}
Expand Down

0 comments on commit abe14c8

Please sign in to comment.