Skip to content

Commit

Permalink
Prevent scroll hide for touch devices
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemBaskal committed Jun 17, 2020
1 parent 62da979 commit 4c30a58
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
55 changes: 26 additions & 29 deletions client/src/components/Logs/Tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,34 @@ import PropTypes from 'prop-types';
import ReactTooltip from 'react-tooltip';
import classNames from 'classnames';
import './ReactTooltip.css';
import { TouchMediaQuery } from '../../../helpers/constants';

class Tooltip extends React.Component {
render() {
const {
id, children, className = '', place = 'right', trigger = 'hover', overridePosition, scrollHide = true,
} = this.props;
const Tooltip = ({
id, children, className = '', place = 'right', trigger = 'hover', overridePosition, scrollHide = true,
}) => {
const tooltipClassName = classNames('custom-tooltip', className);

const tooltipClassName = classNames('custom-tooltip', className);

return (
<ReactTooltip
id={id}
aria-haspopup="true"
effect="solid"
place={place}
className={tooltipClassName}
backgroundColor="#fff"
arrowColor="transparent"
textColor="#4d4d4d"
delayHide={300}
scrollHide={scrollHide}
trigger={trigger}
overridePosition={overridePosition}
globalEventOff="click touchend"
clickable
>
{children}
</ReactTooltip>
);
}
}
return (
<ReactTooltip
id={id}
aria-haspopup="true"
effect="solid"
place={place}
className={tooltipClassName}
backgroundColor="#fff"
arrowColor="transparent"
textColor="#4d4d4d"
delayHide={300}
scrollHide={window.matchMedia(TouchMediaQuery).matches ? false : scrollHide}
trigger={trigger}
overridePosition={overridePosition}
globalEventOff="click touchend"
clickable
>
{children}
</ReactTooltip>
);
};

Tooltip.propTypes = {
id: PropTypes.string.isRequired,
Expand Down
2 changes: 2 additions & 0 deletions client/src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,5 @@ export const FORM_NAME = {
};

export const smallScreenSize = 767;

export const TouchMediaQuery = '(hover: none)';

0 comments on commit 4c30a58

Please sign in to comment.