Skip to content

See how your app actually fits together. An interactive, plain-English map of your codebase, drawn by Claude or Codex.

Map: no hover tooltip after a tap, and a tooltip stays on a narrow screen

Hayden Smith3da7d675412c
diff --git a/skills/floorplan/assets/viewer.html b/skills/floorplan/assets/viewer.html
index 4b0ded8..bd7c4a8 100644
--- a/skills/floorplan/assets/viewer.html
+++ b/skills/floorplan/assets/viewer.html
@@ -1141,7 +1141,10 @@ function drawColumns(g, view, res) {
// ======================= tooltips =======================
const tip = $('#tooltip');
let tipTimer = null, lastPointer = null;
-function showTip(ev, html) { clearTimeout(tipTimer); if (!html || drag?.moved || !$('#ctxmenu').hidden) return; tip.innerHTML = html; tip.hidden = false; moveTip(ev); }
+// a tap also sends mouseenter, so remember whether the last pointer was a finger: hover tooltips are for a mouse
+let touching = false;
+['pointerdown', 'pointermove'].forEach((t) => window.addEventListener(t, (ev) => { touching = ev.pointerType === 'touch'; }, { capture: true, passive: true }));
+function showTip(ev, html) { clearTimeout(tipTimer); if (!html || touching || drag?.moved || !$('#ctxmenu').hidden) return; tip.innerHTML = html; tip.hidden = false; moveTip(ev); }
/** Cards explain themselves after a short hover, so passing over them doesn't flicker tooltips. */
function tipSoon(ev, make) { clearTimeout(tipTimer); lastPointer = ev; tipTimer = setTimeout(() => showTip(lastPointer, make()), 420); }
function moveTip(ev) {
@@ -1151,7 +1154,7 @@ function moveTip(ev) {
let x = ev.clientX - r.left + 18, y = ev.clientY - r.top + 18;
if (x + tip.offsetWidth + 12 > r.width) x = ev.clientX - r.left - tip.offsetWidth - 14;
if (y + tip.offsetHeight + 12 > r.height) y = ev.clientY - r.top - tip.offsetHeight - 14;
- tip.style.left = x + 'px'; tip.style.top = y + 'px';
+ tip.style.left = Math.max(8, x) + 'px'; tip.style.top = Math.max(8, y) + 'px'; // flipped on a narrow screen, it still stays on it
}
function hideTip() { clearTimeout(tipTimer); tip.hidden = true; }
function endpointsOf(e) {
diff --git a/tests/touch.test.mjs b/tests/touch.test.mjs
index c9bff3d..8e98a1c 100644
--- a/tests/touch.test.mjs
+++ b/tests/touch.test.mjs
@@ -33,6 +33,12 @@ test('a third finger is ignored, and the click that ends a drag is swallowed onc
assert.match(html, /if \(ev\.pointerType === 'touch'\) \{\n if \(fingers\.size >= 2\) return; \/\/ a third finger is ignored/);
});
+test('a tap does not leave a hover tooltip over the details, and a tooltip stays on a narrow screen', () => {
+ assert.match(html, /\(ev\) => \{ touching = ev\.pointerType === 'touch'; \}/);
+ assert.match(html, /if \(!html \|\| touching \|\| drag\?\.moved/);
+ assert.match(html, /tip\.style\.left = Math\.max\(8, x\) \+ 'px'; tip\.style\.top = Math\.max\(8, y\) \+ 'px';/);
+});
+
test('none of this changes a mouse: the glide is only cancelled for a finger, and a mouse drag keeps its original one-time click guard', () => {
assert.match(html, /if \(ev\.pointerType === 'touch'\) swallowClick = true; else svg\.addEventListener\('click', \(e\) => e\.stopPropagation\(\), \{ capture: true, once: true \}\)/);
assert.match(html, /svg\.addEventListener\('click', \(\) => select\(null\)\);/);