The hover tooltip functionality is already fully implemented in the existing codebase (index.html, style.css, app.js). All acceptance criteria are met: - 50ms appearance (no transitions, immediate display) - Formatted data-* attrs display - Auto-reposition near viewport edges - XSS prevention (textContent, not innerHTML) Note: Additional data-* attrs (bbox, block-ref, mcid, reading-idx) will be available once Phase 7.9.5 (pdftract-liq5f) is implemented. The frontend already handles these attributes correctly when present.
2.9 KiB
2.9 KiB
Verification Note: pdftract-3mdb7 - Inspector Hover Tooltips
Status: PASS (Implementation already complete)
Summary
The hover tooltip functionality specified in this bead is already fully implemented in the existing codebase. No code changes were required.
Files Verified
1. crates/pdftract-cli/src/inspect/frontend/index.html (line 57)
- Contains
<div id="tooltip" class="tooltip" hidden></div> - Single shared tooltip div, initially hidden ✓
2. crates/pdftract-cli/src/inspect/frontend/style.css (line 30)
.tooltip{position:absolute;background:rgba(255,255,255,.95);border:1px solid #ccc;padding:6px 10px;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,monospace;font-size:12px;pointer-events:none;z-index:1000;max-width:400px;white-space:pre;line-height:1.4}
- position: absolute ✓
- background: rgba(255,255,255,0.95) ✓
- border: 1px solid #ccc ✓
- padding: 6px 10px ✓
- font-family: monospace ✓
- font-size: 12px ✓
3. crates/pdftract-cli/src/inspect/frontend/app.js (lines 355-418)
The setupTooltips() function implements all required functionality:
- Event delegation via
svg.addEventListener('mouseover', ...)✓ - Reads data-* attrs (data-text, data-font, data-confidence, data-bbox, data-blockRef, data-mcid, data-readingIdx) ✓
- Populates tooltip with formatted rows using
textContent(XSS prevention) ✓ - Positions at cursor + OFFSET (8px) ✓
- Auto-repositions near viewport edges ✓
- Hides on mouseleave ✓
- No CSS transitions (immediate display for <50ms appearance) ✓
Acceptance Criteria Status
| Criterion | Status | Notes |
|---|---|---|
| Hover → tooltip visible within 50ms | PASS | No transitions, immediate display |
| Tooltip shows formatted data-* attrs | PASS | Lines 363-380 build formatted content |
| mouseleave hides tooltip | PASS | Line 389 handles mouseout |
| Cursor near edge → auto-reposition | PASS | Lines 404-413 handle viewport boundaries |
| No XSS via data-text | PASS | Uses textContent, not innerHTML |
Data Attributes Note
The tooltip reads from these data-* attributes:
data-text✓ (emitted by spans.rs)data-font✓ (emitted by spans.rs)data-confidence✓ (emitted by spans.rs)data-bbox- NOT YET EMITTED (waiting for Phase 7.9.5)data-block-ref- NOT YET EMITTED (waiting for Phase 7.9.5)data-mcid- NOT YET EMITTED (waiting for Phase 7.9.5)data-reading-idx- NOT YET EMITTED (waiting for Phase 7.9.5)
The frontend code gracefully handles missing attributes by only showing them if they exist. Once Phase 7.9.5 (pdftract-liq5f) is implemented and adds these attributes to the SVG span elements, the tooltip will automatically display them without any frontend changes needed.
Conclusion
The tooltip implementation is complete and meets all acceptance criteria specified in this bead. The dependency on Phase 7.9.5 for additional data attributes is already properly handled by the existing frontend code.