Skip to content

Phase 2 (6/6): fix district search tooltip bug; skip touch-tap here deliberately - #462

Open
JeffreyBLewis wants to merge 1 commit into
touch-tooltips-personfrom
touch-tooltips-district
Open

Phase 2 (6/6): fix district search tooltip bug; skip touch-tap here deliberately#462
JeffreyBLewis wants to merge 1 commit into
touch-tooltips-personfrom
touch-tooltips-district

Conversation

@JeffreyBLewis

Copy link
Copy Markdown
Collaborator

Summary

Stacks on #461 so this diff only shows the new commit, `361cfa7`. This completes Phase 2 (#449).

Last of the 6 tooltip sites, and structurally different: a plain jQuery mouseover/mouseout on each district-search-result table row (not an SVG chart).

Found a real, currently-live bug: the handler was an arrow function using `$(this)`, which doesn't rebind `this` -- it resolved to the enclosing scope, not the row, so `.offset()` returned `undefined` and threw on every hover. The tooltip has never actually worked. Confirmed before/after with a temporary local test harness (loaded `district.js` directly against real `/api/districtLookup` data, removed after testing -- never part of any commit). Fixed by using `tr`, already the correct row reference in scope.

Deliberately did not add touch-tap support here. Each row already has its own click handler that navigates to the member's full bio page. Tested and confirmed: a tap on touch navigates immediately, so a competing tap-to-show-tooltip binding would flash the tooltip and then get superseded by navigation anyway -- real complexity (the same one-dismiss-listener-for-N-rows split as party.js/committee.js, since there can be 100+ rows) for no benefit. Left it hover-only; touch users reach the same info via the navigation they already have.

Test plan

Verified with headless Chromium:

  • Desktop (mouse): hover now correctly shows the tooltip with content and hides on mouseout (previously threw and never appeared at all)
  • Touch: confirmed tapping a row still navigates to the member's page, unaffected
  • Full existing 41-check suite (unrelated files, sanity check only) still passes
  • Manual check on an actual touch/mouse device, if you get a chance

🤖 Generated with Claude Code

https://claude.ai/code/session_013KJMYfgTNsxrmjHZpZKAHT

…rt (Phase 2, site 6 of 6)

Last of the 6 tooltip sites from #449, and structurally different from
the other 5: a plain jQuery mouseover/mouseout on each search-result
table row (not an SVG chart), showing the member's ideology score.

Found a real, currently-live bug while looking at this one: the handler
was `tr.on("mouseover", () => { ... $(this) ... })` -- an arrow function,
which doesn't rebind `this` the way a normal function does. `this` inside
resolved to the enclosing scope, not the row, so `$(this).children(...)
.offset()` returned undefined and `.offset().left` threw a TypeError on
every hover. The tooltip has never actually shown up. Confirmed by
running the exact code (via a temporary local harness loading district.js
directly against real /api/districtLookup data, removed after testing)
before and after the fix. Fixed by using `tr`, already the correct row
reference in scope, instead of `$(this)`; also dropped a leftover debug
console.log that had the same bug and would have thrown first regardless.

Considered, then deliberately skipped, adding touch-tap support here:
each row already has its own click handler that navigates to the
member's full bio page (same ideology score, fuller context). Testing
confirmed a tap on touch navigates immediately -- so a competing tap-to-
show-tooltip binding would show the tooltip for a moment and then get
superseded by the navigation anyway, adding real complexity (the same
one-dismiss-listener-for-N-rows split used in party.js/committee.js,
needed here too since there can be 100+ result rows) for no actual
benefit. Left it hover-only, matching mouse behavior; touch users reach
the same information via the tap-to-navigate they already have.

Verified with headless Chromium:
- Desktop (mouse): hover now correctly shows the tooltip with content
  and hides on mouseout (previously threw and never appeared)
- Touch: confirmed tapping a row still navigates to the member's page
  (unaffected -- nothing here was touching that handler)
- Full existing 41-check suite (unrelated files, sanity check only)
  still passes

This completes Phase 2 (#449) -- all 6 tooltip sites across the 5 listed
files (vote map, party map + ideology chart, committee ideology chart,
person ideology bucket, district search results) now handle touch
appropriately, whether that means adding tap support or, as here,
recognizing it wouldn't add anything.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KJMYfgTNsxrmjHZpZKAHT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant