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

Commit

Permalink
fix(Select): change how we default the list startIconAs
Browse files Browse the repository at this point in the history
The `css` prop doesn't work in the default props, so we have to do it
elsewhere.
  • Loading branch information
justinanastos committed Mar 8, 2021
1 parent de95a8a commit 233b92f
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ const ListItemWrapper: React.FC<ListItemWrapperProps> = ({

return (
<ClassNames>
{({ css }) => {
return renderListItem(
{({ css, cx }) => {
const listItem = renderListItem(
{
className: css({ alignItems: "baseline" }),
key: element.props.value || element.props.children,
...downshiftItemProps,
highlighted: downshiftItemProps["aria-selected"] === "true",
Expand All @@ -127,6 +126,15 @@ const ListItemWrapper: React.FC<ListItemWrapperProps> = ({
},
element,
);

return React.cloneElement(listItem, {
className: cx(
listItem.props.className,
css`
align-items: baseline;
`,
),
});
}}
</ClassNames>
);
Expand Down Expand Up @@ -266,7 +274,7 @@ export const Select: React.FC<Props> = ({
disabled = false,
feel,
labelPropsCallbackRef,
listAs = <List startIconAs={<div css={{ alignSelf: "baseline" }} />} />,
listAs = <List />,
margin = "auto",
matchTriggerWidth,
onBlur,
Expand Down Expand Up @@ -469,6 +477,17 @@ export const Select: React.FC<Props> = ({
listAs,
{
margin,
startIconAs: React.cloneElement(
listAs.props.startIconAs || <div />,
{
className: cx(
css`
align-self: baseline;
`,
listAs.props.startIconAs?.props?.className,
),
},
),
truncate,
...getMenuProps(undefined, { suppressRefError: true }),
...(id && { id: `${id}-menu` }),
Expand Down

0 comments on commit 233b92f

Please sign in to comment.