Skip to content

Commit

Permalink
fix(ListBox): better typing
Browse files Browse the repository at this point in the history
  • Loading branch information
LexSwed committed Dec 9, 2020
1 parent c6d2fc6 commit ed02efd
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/lib/ListBox/ListBox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FocusScope, useFocusManager } from '@react-aria/focus';
import { StitchesProps } from '@stitches/react';
import React from 'react';

import { styled } from '../stitches.config';
Expand Down Expand Up @@ -29,22 +30,23 @@ const ListInner: React.FC<{ wrap?: boolean }> = ({ wrap, ...props }) => {

ListInner.displayName = 'ListBox.Inner';

const ListBox = React.forwardRef<
HTMLUListElement,
React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement> & {
restoreFocus?: boolean;
contain?: boolean;
wrap?: boolean;
interface Props extends StitchesProps<typeof List> {
restoreFocus?: boolean;
contain?: boolean;
wrap?: boolean;
}

const ListBox = React.forwardRef<HTMLUListElement, Props>(
({ children, restoreFocus, contain, wrap, ...props }, ref) => {
return (
<List role="listbox" tabIndex={-1} {...props} as="ul" ref={ref}>
<FocusScope contain={contain} restoreFocus={restoreFocus}>
<ListInner wrap={wrap}>{children}</ListInner>
</FocusScope>
</List>
);
}
>(({ children, restoreFocus, contain, wrap, ...props }, ref) => {
return (
<List role="listbox" tabIndex={-1} {...props} as="ul" ref={ref}>
<FocusScope contain={contain} restoreFocus={restoreFocus}>
<ListInner wrap={wrap}>{children}</ListInner>
</FocusScope>
</List>
);
});
);

ListInner.displayName = 'ListBox';

Expand Down

1 comment on commit ed02efd

@vercel
Copy link

@vercel vercel bot commented on ed02efd Dec 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.