From d154456ae52c349d5858bfc51dd293fe2bf3c1fe Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Sat, 1 Aug 2020 13:38:26 +0300 Subject: [PATCH 1/2] - client: tooltip show delay --- client/src/components/ui/Tooltip.js | 13 +++++++++---- client/src/helpers/constants.js | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/client/src/components/ui/Tooltip.js b/client/src/components/ui/Tooltip.js index 69227d20..d5cc31e8 100644 --- a/client/src/components/ui/Tooltip.js +++ b/client/src/components/ui/Tooltip.js @@ -5,8 +5,8 @@ import { useTranslation } from 'react-i18next'; import { HIDE_TOOLTIP_DELAY, - HIDE_TOOLTIP_CLICK_DELAY, MEDIUM_SCREEN_SIZE, + SHOW_TOOLTIP_DELAY, } from '../../helpers/constants'; import 'react-popper-tooltip/dist/styles.css'; import './Tooltip.css'; @@ -18,22 +18,26 @@ const Tooltip = ({ className = 'tooltip-container', placement = 'bottom', trigger = 'hover', + delayShow = SHOW_TOOLTIP_DELAY, delayHide = HIDE_TOOLTIP_DELAY, }) => { const { t } = useTranslation(); let triggerValue = trigger; - let delayValue = delayHide; + let delayHideValue = delayHide; + let delayShowValue = delayShow; if (window.matchMedia(`(max-width: ${MEDIUM_SCREEN_SIZE}px)`).matches) { triggerValue = 'click'; - delayValue = HIDE_TOOLTIP_CLICK_DELAY; + delayHideValue = 0; + delayShowValue = 0; } return ( (
Date: Sat, 1 Aug 2020 16:25:56 +0300 Subject: [PATCH 2/2] - client: check touch events for tooltips --- client/src/components/ui/Tooltip.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/components/ui/Tooltip.js b/client/src/components/ui/Tooltip.js index d5cc31e8..284a53a3 100644 --- a/client/src/components/ui/Tooltip.js +++ b/client/src/components/ui/Tooltip.js @@ -22,11 +22,13 @@ const Tooltip = ({ delayHide = HIDE_TOOLTIP_DELAY, }) => { const { t } = useTranslation(); + const touchEventsAvailable = 'ontouchstart' in window; + let triggerValue = trigger; let delayHideValue = delayHide; let delayShowValue = delayShow; - if (window.matchMedia(`(max-width: ${MEDIUM_SCREEN_SIZE}px)`).matches) { + if (window.matchMedia(`(max-width: ${MEDIUM_SCREEN_SIZE}px)`).matches || touchEventsAvailable) { triggerValue = 'click'; delayHideValue = 0; delayShowValue = 0;