Fix HTML5Badge tooltip on mobile

This commit is contained in:
Emi Matchu 2021-02-10 13:10:17 -08:00
parent 2403bd813a
commit bf85cef922

View file

@ -980,12 +980,19 @@ function HTML5Badge({ usesHTML5, isLoading }) {
} }
function HTML5BadgeLayout({ children, tooltipLabel, ...props }) { function HTML5BadgeLayout({ children, tooltipLabel, ...props }) {
const [isHovered, setIsHovered] = React.useState(false);
const [isFocused, setIsFocused] = React.useState(false);
return ( return (
<Tooltip <Tooltip
textAlign="center" textAlign="center"
fontSize="xs" fontSize="xs"
placement="bottom-start" placement="bottom-start"
label={tooltipLabel} label={tooltipLabel}
// HACK: Chakra tooltips seem inconsistent about staying open when focus
// comes from touch events. But I really want this one to work on
// mobile!
isOpen={isHovered || isFocused}
> >
<Flex <Flex
align="center" align="center"
@ -997,6 +1004,10 @@ function HTML5BadgeLayout({ children, tooltipLabel, ...props }) {
transition="all 0.2s" transition="all 0.2s"
tabIndex="0" tabIndex="0"
_focus={{ outline: "none", boxShadow: "outline" }} _focus={{ outline: "none", boxShadow: "outline" }}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
{...props} {...props}
> >
{children} {children}