diff --git a/src/admin/components/elements/Button/index.scss b/src/admin/components/elements/Button/index.scss
index 4acd9ae871..5662fb3a27 100644
--- a/src/admin/components/elements/Button/index.scss
+++ b/src/admin/components/elements/Button/index.scss
@@ -22,22 +22,6 @@
&--has-tooltip {
position: relative;
-
- }
-
- .btn__tooltip {
- opacity: 0;
- visibility: hidden;
- transform: translate(-50%, -10px);
- }
-
- .btn__content {
- &:hover {
- .btn__tooltip {
- opacity: 1;
- visibility: visible;
- }
- }
}
&--icon-style-without-border {
diff --git a/src/admin/components/elements/Button/index.tsx b/src/admin/components/elements/Button/index.tsx
index 2f9a89963f..5fb02e76f6 100644
--- a/src/admin/components/elements/Button/index.tsx
+++ b/src/admin/components/elements/Button/index.tsx
@@ -1,4 +1,4 @@
-import React, { isValidElement } from 'react';
+import React, { Fragment, isValidElement } from 'react';
import { Link } from 'react-router-dom';
import { Props } from './types';
@@ -21,31 +21,31 @@ const icons = {
const baseClass = 'btn';
-const ButtonContents = ({ children, icon, tooltip }) => {
+const ButtonContents = ({ children, icon, tooltip, showTooltip }) => {
const BuiltInIcon = icons[icon];
return (
-
+
{tooltip}
- {children && (
-
- {children}
-
- )}
- {icon && (
-
- {isValidElement(icon) && icon}
- {BuiltInIcon && }
-
- )}
-
+
+ {children && (
+
+ {children}
+
+ )}
+ {icon && (
+
+ {isValidElement(icon) && icon}
+ {BuiltInIcon && }
+
+ )}
+
+
);
};
@@ -70,6 +70,8 @@ const Button: React.FC = (props) => {
tooltip,
} = props;
+ const [showTooltip, setShowTooltip] = React.useState(false);
+
const classes = [
baseClass,
className && className,
@@ -85,6 +87,7 @@ const Button: React.FC = (props) => {
].filter(Boolean).join(' ');
function handleClick(event) {
+ setShowTooltip(false);
if (type !== 'submit' && onClick) event.preventDefault();
if (onClick) onClick(event);
}
@@ -94,6 +97,8 @@ const Button: React.FC = (props) => {
type,
className: classes,
disabled,
+ onMouseEnter: tooltip ? () => setShowTooltip(true) : undefined,
+ onMouseLeave: tooltip ? () => setShowTooltip(false) : undefined,
onClick: !disabled ? handleClick : undefined,
rel: newTab ? 'noopener noreferrer' : undefined,
target: newTab ? '_blank' : undefined,
@@ -109,6 +114,7 @@ const Button: React.FC = (props) => {
{children}
@@ -124,6 +130,7 @@ const Button: React.FC = (props) => {
{children}
@@ -141,6 +148,7 @@ const Button: React.FC = (props) => {
{children}
diff --git a/src/admin/components/elements/CopyToClipboard/index.scss b/src/admin/components/elements/CopyToClipboard/index.scss
index 3adcc1d55b..227dd59722 100644
--- a/src/admin/components/elements/CopyToClipboard/index.scss
+++ b/src/admin/components/elements/CopyToClipboard/index.scss
@@ -14,22 +14,8 @@
width: 0px;
}
- .tooltip {
- pointer-events: none;
- opacity: 0;
- visibility: hidden;
- }
-
&:focus,
&:active {
outline: none;
}
-
- &:hover {
- .tooltip {
- opacity: 1;
- visibility: visible;
-
- }
- }
}
diff --git a/src/admin/components/elements/CopyToClipboard/index.tsx b/src/admin/components/elements/CopyToClipboard/index.tsx
index 85e210e75b..e108412222 100644
--- a/src/admin/components/elements/CopyToClipboard/index.tsx
+++ b/src/admin/components/elements/CopyToClipboard/index.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useState, useRef } from 'react';
+import React, { useState, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import Copy from '../../icons/Copy';
import Tooltip from '../Tooltip';
@@ -18,14 +18,6 @@ const CopyToClipboard: React.FC = ({
const [hovered, setHovered] = useState(false);
const { t } = useTranslation('general');
- useEffect(() => {
- if (copied && !hovered) {
- setTimeout(() => {
- setCopied(false);
- }, 1500);
- }
- }, [copied, hovered]);
-
if (value) {
return (