fix(map): fermer le tooltip au tap hors département (mobile)
Some checks are pending
Deploy info-canicule / deploy (push) Waiting to run

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) <noreply@anthropic.com>
This commit is contained in:
Florian 2026-05-26 19:16:01 +02:00
parent fcfc858299
commit 8638b260ff

View file

@ -193,9 +193,18 @@ for (const [code] of entries) {
tooltip.dataset.code = t.getAttribute('data-code'); tooltip.dataset.code = t.getAttribute('data-code');
const rect = t.getBoundingClientRect(); const rect = t.getBoundingClientRect();
show(t, { clientX: rect.left + rect.width / 2, clientY: rect.top }); show(t, { clientX: rect.left + rect.width / 2, clientY: rect.top });
setTimeout(function () { tooltip.dataset.code = ''; }, 3000);
} }
} }
}, { passive: false }); }, { 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();
}
});
})(); })();
</script> </script>