Skip to content

Commit

Permalink
feat(Popover): add zIndex property (#3919)
Browse files Browse the repository at this point in the history
  • Loading branch information
mainframev committed Jul 11, 2023
1 parent 9119426 commit 36a8d21
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/orbit-components/src/Popover/Popover.stories.tsx
Expand Up @@ -426,6 +426,7 @@ ScrollingContent.story = {

export const Playground = () => {
const renderTimeout = number("renderTimeout", 0);
const zIndex = number("zIndex", 710);
const dataTest = text("dataTest", "test");
const placement = select("placement", Object.values(PLACEMENTS), PLACEMENTS.BOTTOM_START);
const width = text("width", "350px");
Expand All @@ -442,6 +443,7 @@ export const Playground = () => {
<Stack justify="center">
<Popover
width={width}
zIndex={zIndex}
maxHeight={maxHeight}
renderTimeout={renderTimeout}
dataTest={dataTest}
Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/Popover/README.md
Expand Up @@ -41,6 +41,7 @@ The table below contains all types of props available in the Popover component.
| allowOverflow | `boolean` | `false` | Allows the Popover to be cut off instead of moving it while scrolling to keep it visible. |
| labelClose | `React.Node` | `Close` | The label for close button. |
| renderTimeout | `number` | `0` | The timeout for rendering the Popover. |
| zIndex | `number` | `710` | The zIndex value of the Popover component. |

## enum

Expand Down
Expand Up @@ -10,7 +10,7 @@ import Stack from "../../Stack";
jest.mock("../../hooks/useMediaQuery", () => {
return () => {
return {
isTablet: false,
isTablet: true,
};
};
});
Expand Down
Expand Up @@ -27,6 +27,7 @@ export interface Props extends Common.Globals {
referenceElement: HTMLElement | null;
placement: Placement;
width?: string;
zIndex?: number;
maxHeight?: string;
noFlip?: boolean;
allowOverflow?: boolean;
Expand Down Expand Up @@ -108,6 +109,7 @@ const StyledPopoverParent = styled.div<{
width?: string | number;
shown?: boolean;
fixed?: boolean;
$zIndex?: number;
transform?: string;
overlapped?: boolean;
noPadding?: boolean;
Expand All @@ -117,7 +119,19 @@ const StyledPopoverParent = styled.div<{
right?: string | number;
position?: string;
}>`
${({ isInsideModal, width, shown, theme, transform, top, left, bottom, right, position }) => css`
${({
isInsideModal,
width,
shown,
theme,
transform,
top,
left,
bottom,
right,
position,
$zIndex,
}) => css`
position: fixed;
bottom: 0;
left: 0;
Expand All @@ -141,7 +155,7 @@ const StyledPopoverParent = styled.div<{
transform: ${transform};
transition: ${transition(["opacity"], "fast", "ease-in-out")};
position: ${position};
z-index: ${isInsideModal ? "1000" : "710"};
z-index: ${isInsideModal ? "1000" : $zIndex};
width: ${width ? `${width}` : "auto"};
border-radius: ${theme.orbit.borderRadiusNormal};
box-shadow: ${theme.orbit.boxShadowRaised};
Expand Down Expand Up @@ -220,6 +234,7 @@ StyledPopoverClose.defaultProps = {
const PopoverContentWrapper = ({
children,
onClose,
zIndex = 710,
labelClose,
width,
maxHeight,
Expand Down Expand Up @@ -303,6 +318,7 @@ const PopoverContentWrapper = ({
<StyledPopoverParent
width={width}
ref={popoverRef}
$zIndex={zIndex}
tabIndex={0}
data-test={dataTest}
id={id}
Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/Popover/index.js.flow
Expand Up @@ -34,6 +34,7 @@ export type Props = {|
+renderInPortal?: boolean,
+onOpen?: () => void | Promise<any>,
+onClose?: () => void | Promise<any>,
+zIndex?: number,
|};

declare export default React.ComponentType<Props>;
2 changes: 2 additions & 0 deletions packages/orbit-components/src/Popover/index.tsx
Expand Up @@ -16,6 +16,7 @@ const Popover = ({
children,
renderInPortal = true,
opened,
zIndex,
content,
onClose,
id,
Expand Down Expand Up @@ -127,6 +128,7 @@ const Popover = ({
id={id}
labelClose={labelClose}
dataTest={dataTest}
zIndex={zIndex}
overlapped={overlapped}
fixed={fixed}
noFlip={noFlip}
Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/Popover/types.d.ts
Expand Up @@ -31,4 +31,5 @@ export interface Props extends Common.Globals {
readonly onOpen?: Common.Callback;
readonly renderInPortal?: boolean;
readonly onClose?: Common.Callback;
readonly zIndex?: number;
}

0 comments on commit 36a8d21

Please sign in to comment.