Inherits error props to tooltip wrapper child buttons (#2307)

This commit is contained in:
Alex
2022-09-12 01:29:30 -05:00
committed by GitHub
parent cc581c6a9e
commit 7728cc734a

View File

@@ -14,18 +14,25 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from "react";
import React, { cloneElement } from "react";
import { Tooltip } from "@mui/material";
interface ITooltipWrapperProps {
tooltip: string;
children: any;
errorProps?: any;
}
const TooltipWrapper = ({ tooltip, children }: ITooltipWrapperProps) => {
const TooltipWrapper = ({
tooltip,
children,
errorProps = null,
}: ITooltipWrapperProps) => {
return (
<Tooltip title={tooltip}>
<span>{children}</span>
<span>
{errorProps ? cloneElement(children, { ...errorProps }) : children}
</span>
</Tooltip>
);
};