Fix annotation highlight loss, popup mispositioning, composer clutter - #54
Merged
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four annotation-layer bugs, root-caused against the actual bundled source of
@recogito/react-text-annotator/@annotorious/core4.2.5 (confirmed as the current latest release — no upstream fix exists yet) rather than patched by symptom: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
ResizeObserveron the container — neither reliably fires for a layout shift caused by a sibling elsewhere on the page. Added aResizeObserveron the container's parent + aMutationObserveron<body>that dispatch a realresizeevent when triggered, routing recovery through Recogito's own already-correct resize path.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.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 sharedcancelCurrentSelectionfunction 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.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 (visibleThreadsmemoization for a related flag-click reliability issue) via a clean merge — no conflicts, verified they compose correctly together.Test plan
npx tsc --noEmitcleannpx eslint .clean🤖 Generated with Claude Code