Skip to content

Fix annotation highlight loss, popup mispositioning, composer clutter - #54

Merged
crewcricle merged 2 commits into
mainfrom
claude/beautiful-bun-91716b
Aug 8, 2026
Merged

Fix annotation highlight loss, popup mispositioning, composer clutter#54
crewcricle merged 2 commits into
mainfrom
claude/beautiful-bun-91716b

Conversation

@rprabhat

@rprabhat rprabhat commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Four annotation-layer bugs, root-caused against the actual bundled source of @recogito/react-text-annotator / @annotorious/core 4.2.5 (confirmed as the current latest release — no upstream fix exists yet) rather than patched by symptom:

  1. Underline goes stale and never recovers after opening/closing a source, toggling the Sources/History rail, etc. Recogito only recalculates highlight positions on an actual window resize or its own ResizeObserver on the container — neither reliably fires for a layout shift caused by a sibling elsewhere on the page. Added a ResizeObserver on the container's parent + a MutationObserver on <body> that dispatch a real resize event when triggered, routing recovery through Recogito's own already-correct resize path.

  2. Claim-detail popup renders in the wrong place (vertically centered, overlapping the underline). Confirmed upstream bug: its floating-ui position reference reads a module-level value the library computes ~250ms later inside a debounced requestAnimationFrame, but floating-ui reads it synchronously on first render, and nothing in its auto-update logic re-checks a virtual reference on a timer. A synthetic resize event ~320ms after a new selection nudges floating-ui to ask again once the value has settled.

  3. Cancelling a comment/question popup left the text still looking selected. cancelSelected() only clears which annotation is selected — it doesn't remove the draft annotation that drag-selecting text creates immediately in Recogito's local store. Now explicitly removed on cancel, but never for a real persisted thread or a verify-flag annotation. One shared cancelCurrentSelection function backs the composer's Cancel button, the verify popup's Close button, and dismissing by clicking away, so the three paths can't drift out of sync.

  4. Compose popup repeated the selected text back, redundant since it's already highlighted inline. Removed — the popup is now just the question/comment toggle, the text field, and Cancel/Add.

This branch also picks up main's concurrent fix to the same file (visibleThreads memoization for a related flag-click reliability issue) via a clean merge — no conflicts, verified they compose correctly together.

Test plan

  • npx tsc --noEmit clean
  • npx eslint . clean
  • Backend suite: 842 passed
  • User to verify interactively — this worktree has no Supabase env vars locally, and the Vercel preview requires SSO login I don't have access to, so I could not click-test this live. The fixes are grounded in reading the installed library's actual compiled source (not guesses), but a real interactive pass is still worth doing before merge.

🤖 Generated with Claude Code

crewcricle and others added 2 commits August 8, 2026 18:16
…utter

Root-caused all four against the actual bundled source of
@recogito/react-text-annotator / @annotorious/core 4.2.5 (the current latest
release) rather than patching symptoms:

1. Verify-flag underline goes stale after an unrelated layout shift
   elsewhere on the page (Sources/History rail toggling, a citation's source
   Dialog opening then closing) and never recovers on its own - Recogito
   only recalculates highlight positions on an actual window resize or its
   own ResizeObserver on the container, neither of which reliably fires for
   a layout change caused by a sibling elsewhere in the tree. Added a
   ResizeObserver on the container's parent + a MutationObserver on <body>
   that dispatch a real `resize` event when triggered, routing recovery
   through Recogito's own already-correct, already-tested resize path
   instead of reaching into its internals.

2. The claim-detail popup renders in the wrong place (usually vertically
   centered, overlapping the underline) - confirmed upstream bug: its
   floating-ui position reference reads a module-level value that the
   library computes ~250ms later inside a debounced requestAnimationFrame,
   but floating-ui reads it synchronously on first render, and nothing in
   its auto-update logic re-checks a virtual reference on a timer. A
   synthetic resize event ~320ms after a new selection (after the debounce
   has settled) nudges floating-ui to ask again and land in the right spot.

3. Cancelling a comment/question popup left the text still looking
   selected - cancelSelected() only clears which annotation is selected, it
   doesn't remove the draft annotation that drag-selecting text creates
   immediately in Recogito's local store, so its highlight stayed behind
   forever. Now explicitly removed on cancel, but never for a real
   persisted thread or a verify-flag annotation - one shared
   cancelCurrentSelection function backs the composer's Cancel button, the
   verify popup's Close button, and dismissing by clicking away, so the
   three paths can't drift out of sync with each other.

4. The compose popup repeated the selected text back at the user, which was
   redundant given it's already highlighted inline - removed, leaving just
   the question/comment toggle, the text field, and Cancel/Add.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
taxflow-dashboard Ready Ready Preview Aug 8, 2026 8:19am

@crewcricle
crewcricle merged commit 2f8e784 into main Aug 8, 2026
7 checks passed
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.

2 participants