Skip to content

Commit

Permalink
fix(popover): remove popovercontainer Box wrapper (#2011)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSisb committed Nov 8, 2021
1 parent 69acc76 commit 847504d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/stale-guests-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@twilio-paste/popover': minor
'@twilio-paste/core': minor
---

[Popover] Removes the wrapping `<Box>` present in `PopoverContainer`, along with the ref passing. PopoverContainer is strictly a context provider now. This fixes issues around vertical alignment and inlining PopoverButtons.
22 changes: 10 additions & 12 deletions packages/paste-core/components/popover/src/PopoverContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import {Box} from '@twilio-paste/box';
import type {
NonModalDialogPrimitiveStateReturn,
NonModalDialogPrimitivePopoverInitialState,
Expand All @@ -16,17 +15,16 @@ export interface PopoverContainerProps extends NonModalDialogPrimitivePopoverIni
state?: PopoverStateReturn;
}

const BasePopoverContainer = React.forwardRef<HTMLDivElement, PopoverContainerProps>(
({children, gutter, placement, state, ...initialState}, ref) => {
const popover = state || useNonModalDialogPrimitiveState({gutter, modal: true, placement, ...initialState});
return (
<PopoverContext.Provider value={popover}>
<Box ref={ref}>{children}</Box>
</PopoverContext.Provider>
);
}
);

const BasePopoverContainer: React.FC<PopoverContainerProps> = ({
children,
gutter,
placement,
state,
...initialState
}) => {
const popover = state || useNonModalDialogPrimitiveState({gutter, modal: true, placement, ...initialState});
return <PopoverContext.Provider value={popover}>{children}</PopoverContext.Provider>;
};
BasePopoverContainer.displayName = 'BasePopoverContainer';

const PopoverContainer = React.memo(BasePopoverContainer);
Expand Down

0 comments on commit 847504d

Please sign in to comment.