From 892838d27e0536836bda7c8350ccb69d689fd3b9 Mon Sep 17 00:00:00 2001 From: maxime Date: Thu, 5 Nov 2026 15:39:11 +0100 Subject: [PATCH] app/: a click elsewhere on the label bar closes the selected event Co-Authored-By: Claude Opus 5.5 --- app/web/src/pages/Data.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/web/src/pages/Data.jsx b/app/web/src/pages/Data.jsx index e2e45e6..24b469a 100644 --- a/app/web/src/pages/Data.jsx +++ b/app/web/src/pages/Data.jsx @@ -184,7 +184,14 @@ function Courbes({ selection: { station, du, au }, d }) { if (r) setChoix(r.map(v => String(v).slice(0, 16).replace(" ", "T") + "Z")); }); barre.current.on("plotly_deselect", () => setChoix(null)); - barre.current.on("plotly_click", ev => courant.current.ouvrir(tries.current[ev.points[0].pointIndex])); + // Un clic sur une étiquette l'ouvre ; un clic ailleurs sur la barre (pas un glisser) la referme + let surEtiquette = false, x0 = 0; + barre.current.on("plotly_click", ev => { surEtiquette = true; courant.current.ouvrir(tries.current[ev.points[0].pointIndex]); }); + barre.current.addEventListener("mousedown", e => { x0 = e.clientX; }, true); + barre.current.addEventListener("click", e => { + if (!surEtiquette && Math.abs(e.clientX - x0) < 4) courant.current.ouvrir(null); + surEtiquette = false; + }); setPret(true); }); return () => [...Object.values(figs.current), barre.current].forEach(g => g && Plotly.purge(g));