Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only render tooltip on hover #368

Merged
merged 1 commit into from
Sep 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions webapp/src/components/link_tooltip/link_tooltip.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import ReactMarkdown from 'react-markdown';
import Client from 'client';
import {getLabelFontColor, hexToRGB} from '../../utils/styles';

export const LinkTooltip = ({href, connected, theme}) => {
export const LinkTooltip = ({href, connected, show, theme}) => {
const [data, setData] = useState(null);
useEffect(() => {
const init = async () => {
const initData = async () => {
if (href.includes('github.com/')) {
const [owner, repo, type, number] = href.split('github.com/')[1].split('/');
let res;
Expand All @@ -30,13 +30,14 @@ export const LinkTooltip = ({href, connected, theme}) => {
setData(res);
}
};
if (data) {

// show is not provided for Mattermost Server < 5.28
if (!connected || data || ((typeof (show) !== 'undefined' || show != null) && !show)) {
return;
}
if (connected) {
init();
}
}, []);

initData();
}, [connected, data, href, show]);

const getIconElement = () => {
let icon;
Expand Down Expand Up @@ -174,4 +175,5 @@ LinkTooltip.propTypes = {
href: PropTypes.string.isRequired,
connected: PropTypes.bool.isRequired,
theme: PropTypes.object.isRequired,
show: PropTypes.bool,
};