Fix the heatmap caption needing several taps
A tap fires the emulated mouseenter and then the click on the same block, and the click handler was a toggle: the first of the pair selected the block, the second cleared it, so one tap left the caption exactly where it started. It only appeared on a later tap that arrived without a fresh mouseenter, which is what made it look like taps were being missed. The click now selects rather than toggles, so running both handlers for one tap is a no-op — the same idempotent shape the weight chart's hit targets already use. Tap-again-to-clear goes with it: telling a hover-set selection apart from a click-set one is more machinery than the affordance is worth, and the caption keeping its last block matches the weight chart's caption. The changelog entry that promised clearing is corrected in place, since the behaviour it describes never worked.
This commit is contained in:
+7
-3
@@ -1557,8 +1557,8 @@
|
||||
svg.innerHTML = parts.concat(hits).join("");
|
||||
|
||||
// <title> tooltips only ever show on a pointer, which left phones with no
|
||||
// way to read a block's count. Tap/hover names the block under the chart;
|
||||
// tapping the focused block again clears it.
|
||||
// way to read a block's count. Tapping (or hovering) a block names it in
|
||||
// the caption under the chart.
|
||||
const cells = svg.querySelectorAll(".hm-cell[data-cell]");
|
||||
const focusCell = (key) => {
|
||||
hourCellSel = details[key] ? key : null;
|
||||
@@ -1567,7 +1567,11 @@
|
||||
};
|
||||
svg.querySelectorAll(".hm-hit").forEach(hit => {
|
||||
const key = hit.dataset.cell;
|
||||
hit.addEventListener("click", () => focusCell(hourCellSel === key ? null : key));
|
||||
// Select, never toggle. A tap fires the emulated mouseenter and then the
|
||||
// click on the same block, so a toggle here selected on the first of the
|
||||
// pair and cleared on the second — the count only appeared on a later tap
|
||||
// that arrived without a fresh mouseenter. Selecting twice is a no-op.
|
||||
hit.addEventListener("click", () => focusCell(key));
|
||||
hit.addEventListener("mouseenter", () => focusCell(key));
|
||||
});
|
||||
focusCell(hourCellSel);
|
||||
|
||||
Reference in New Issue
Block a user