From 8638b260ff1510ec9a8e4bc4835519c18cbccee2 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 26 May 2026 19:16:01 +0200 Subject: [PATCH] =?UTF-8?q?fix(map):=20fermer=20le=20tooltip=20au=20tap=20?= =?UTF-8?q?hors=20d=C3=A9partement=20(mobile)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sur mobile, mouseout ne se déclenche pas après un touchstart : le tooltip restait affiché jusqu'au prochain tap sur un département. Ajout d'un listener pointerdown global qui ferme le tooltip dès qu'on tape ailleurs. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/components/FranceMap.astro | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/FranceMap.astro b/src/components/FranceMap.astro index c81ae33..72dcacc 100644 --- a/src/components/FranceMap.astro +++ b/src/components/FranceMap.astro @@ -193,9 +193,18 @@ for (const [code] of entries) { tooltip.dataset.code = t.getAttribute('data-code'); const rect = t.getBoundingClientRect(); show(t, { clientX: rect.left + rect.width / 2, clientY: rect.top }); - setTimeout(function () { tooltip.dataset.code = ''; }, 3000); } } }, { passive: false }); + + // Fermer le tooltip si on tape ailleurs (mobile : pas de mouseout). + document.addEventListener('pointerdown', function (e) { + const t = e.target; + const onPath = t && t.tagName === 'path' && t.getAttribute('data-code'); + if (!onPath) { + tooltip.dataset.code = ''; + hide(); + } + }); })();