Skip to content

Commit

Permalink
fix type error on Popover close
Browse files Browse the repository at this point in the history
  • Loading branch information
yyanwang committed Oct 23, 2023
1 parent 35263df commit 04d9d95
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/design-system/src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type PopoverProps = {
} & PopoverOptions;

export type PopoverStateReturn = {
hide: () => void;
setOpen: () => void;
};

export function Popover({
Expand Down Expand Up @@ -70,7 +70,10 @@ export function Popover({
fill={tokens.coralColorNeutralBackground}
/>
{typeof children === 'function'
? children({ ...popover.getFloatingProps(), setOpen: popover.setOpen })
? children({
...popover.getFloatingProps(),
setOpen: popover.setOpen,
})
: children}
</div>
</Wrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const WithFunctionAsChildren = () => (
{(popover: PopoverStateReturn) => (
<StackVertical gap="S">
There is some content
<ButtonPrimary onClick={() => popover?.hide()}>Close Me please</ButtonPrimary>
<ButtonPrimary onClick={() => popover?.setOpen(false)}>Close Me please</ButtonPrimary>
</StackVertical>
)}
<EasyPopover />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const BasicSearch = ({
initialFilterValue={initialFilterValue}
onClick={(...args) => {
onClickOverlayRow(...args);
popover?.hide();
popover?.setOpen(false);
}}
t={t}
/>
Expand Down

0 comments on commit 04d9d95

Please sign in to comment.