From 8836659a7bb03109f05fe83dbefc48832d5be969 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:14:03 +0100 Subject: [PATCH] [charts] Prevent invalid `releasePointerCapture` (@alexfauquette) (#15609) Signed-off-by: Jose C Quintas Jr Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com> Co-authored-by: Jose C Quintas Jr --- packages/x-charts/src/hooks/useInteractionItemProps.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/x-charts/src/hooks/useInteractionItemProps.ts b/packages/x-charts/src/hooks/useInteractionItemProps.ts index 49a6e5e70c90b..a25a5f093b791 100644 --- a/packages/x-charts/src/hooks/useInteractionItemProps.ts +++ b/packages/x-charts/src/hooks/useInteractionItemProps.ts @@ -28,7 +28,10 @@ export const useInteractionItemProps = (skip?: boolean) => { }); }; const onPointerLeave = (event: React.PointerEvent) => { - event.currentTarget.releasePointerCapture(event.pointerId); + if (event.currentTarget.hasPointerCapture(event.pointerId)) { + event.currentTarget.releasePointerCapture(event.pointerId); + } + dispatchInteraction({ type: 'leaveItem', data }); clearHighlighted(); };