BarChart: Fix Sticky Tooltip (#45017)

This commit is contained in:
Nathan Marrs 2022-02-07 14:26:27 -08:00 committed by GitHub
parent 01d961c824
commit ed7b9905c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -252,7 +252,7 @@ export const BarChartPanel: React.FunctionComponent<Props> = ({ data, options, w
width={width}
height={height}
>
{(config, alignedFrame) => {
{(config) => {
if (oldConfig.current !== config) {
oldConfig.current = setupConfig({
config,

View File

@ -33,6 +33,11 @@ export const setupConfig = ({
}: SetupConfigParams): UPlotConfigBuilder => {
config.addHook('init', (u) => {
u.root.parentElement?.addEventListener('click', onUPlotClick);
u.over.addEventListener('mouseleave', () => {
if (!isToolTipOpen.current) {
setCoords(null);
}
});
});
let rect: DOMRect;