I am working on accessibility in an app and one of the WCAG requirements is that tooltips are dismissable with esc. This isn't automatically available in the Material UI <Tooltip> component. I know that is is coming in version 5 of Material UI but I have been asked to find a workaround before we uplift to a new version (we are using v4.5.2 right now).
I have investigated using a <ClickAwayListener> and adding onKeyPressed to the <Tooltip> but neither of those seem to have worked.
My code is below
import React from 'react';
import { Tooltip } from '@material-ui/core';
const AccessibleTooltip = (tooltipText, tooltipPlacement, innerElement) => (
<Tooltip
interactive
arrow
title={tooltipText}
placement={tooltipPlacement}
aria-label={tooltipText}
>
{innerElement}
</Tooltip>
);
export default AccessibleTooltip;
I am fairly new to React and Material so some guidance/pointers would be much appreciated