From a18aa4ae2d42563735c10184e5bc53f75c849007 Mon Sep 17 00:00:00 2001
From: KitoC <35714838+KitoC@users.noreply.github.com>
Date: Fri, 23 Aug 2024 13:38:40 +1000
Subject: [PATCH] HELP-7947 popover trigger refs (#330)
* added trigger
props to Container component instead of trying to clone it to children
* 3.2.35
---
lib/components/Popover/Popover.stories.js | 31 +++++++-----
lib/components/Popover/index.js | 62 +++++++++++------------
package-lock.json | 4 +-
package.json | 2 +-
4 files changed, 51 insertions(+), 48 deletions(-)
diff --git a/lib/components/Popover/Popover.stories.js b/lib/components/Popover/Popover.stories.js
index 04ee5c60..b61ced5a 100644
--- a/lib/components/Popover/Popover.stories.js
+++ b/lib/components/Popover/Popover.stories.js
@@ -5,6 +5,7 @@ import Box from "../Box";
import Grid from "../Grid";
import Flex from "../Flex";
import StyledLink from "../StyledLink";
+import Spacer from "../Spacer";
export default {
title: "Components/Popover",
@@ -95,20 +96,22 @@ export const textAlignment = () => (
);
export const DisplayInlineBlock = () => (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
- >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
);
export const tooltipExample = () => (
diff --git a/lib/components/Popover/index.js b/lib/components/Popover/index.js
index 901bb365..bb46eabe 100644
--- a/lib/components/Popover/index.js
+++ b/lib/components/Popover/index.js
@@ -1,4 +1,4 @@
-import React, { cloneElement, useState } from "react";
+import React, { useState } from "react";
import {
useFloating,
autoUpdate,
@@ -18,12 +18,12 @@ import themeGet from "@styled-system/theme-get";
import styled from "styled-components";
import Icon from "../Icon";
import { PropTypes } from "prop-types";
-import Box from "../Box";
import {
getFloatingUiRootElement,
getFloatingUiZIndex,
isRenderedInReactSelectMenu
} from "../../utils/floatingUiHelpers";
+import { layout, space } from "styled-system";
const DIRECTIONS_MAP = {
topLeft: "top-start",
@@ -36,6 +36,15 @@ const DIRECTIONS_MAP = {
bottomRight: "bottom-end"
};
+const Container = styled.div`
+ ${space}
+ ${layout}
+
+ display: ${(props) =>
+ props.inlineBlock ? "inline-block !important" : "block !important"};
+ position: relative;
+`;
+
const TooltipControl = styled.div`
border: none;
background: none;
@@ -267,6 +276,7 @@ export default function Popover({
enableSelectAll,
variant,
ariaLabel,
+ inlineBlock,
...props
}) {
const [visible, setVisible] = useState(false);
@@ -310,32 +320,6 @@ export default function Popover({
tabIndex: "0"
};
- let triggerComponent = null;
-
- if (variant === "tooltip") {
- triggerComponent = (
-
-
-
- );
- } else if (children?.type?.$$typeof === Symbol.for("react.forward_ref")) {
- triggerComponent = cloneElement(children, triggerProps);
- } else {
- triggerComponent = (
-
- {children}
-
- );
- }
-
const directionClass =
context.placement === DIRECTIONS_MAP[direction]
? direction
@@ -363,7 +347,23 @@ export default function Popover({
const containsLinks = refs.floating?.current?.querySelectorAll("a").length;
return (
-
+
+ {variant === "tooltip" && (
+
+
+
+ )}
+
{text &&
(visible ? (
+ {children}
+
);
}
diff --git a/package-lock.json b/package-lock.json
index eff37b8a..2b56e86b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "orcs-design-system",
- "version": "3.2.34",
+ "version": "3.2.35",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "orcs-design-system",
- "version": "3.2.34",
+ "version": "3.2.35",
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
diff --git a/package.json b/package.json
index 62e361ab..b9ccd17d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "orcs-design-system",
- "version": "3.2.34",
+ "version": "3.2.35",
"engines": {
"node": "20.12.2"
},