fix(#141665): keep screenshot markers glued to content when the page scrolls before submit#128
Merged
Merged
Conversation
…lls before submit The capture editor's annotation SVG is position: fixed and drawings are stored in viewport coordinates. When the page scrolled between drawing and the DOM snapshot (scrollbar drag while marking, or scrolling while the feedback form is open after Next), the snapshot recorded the new scroll position and the rendered screenshot showed the marks shifted by exactly that scroll delta. ScreenDrawer now tracks window scrolling relative to the position at drawing start and counter-shifts the overlay via an inline transform, which also serializes into the DOM snapshot so the replayed screenshot stays aligned. Mouse/touch coordinates are mapped into the shifted overlay space so drawing stays under the cursor after a mid-marking scroll. Screen-recording drawings remain viewport-fixed to match the video. The tracker survives ScreenDrawer.destroy() (preview overlay keeps tracking while the form is open) and is released when the capture editor is removed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Anchoring to the drawing-start scroll position left the top strip of the viewport uncovered (and coordinates negative/clipped) when the user scrollbar-dragged above the anchor while marking. Working in document coordinates with transform: translate(-scrollX, -scrollY) keeps the fixed overlay covering the viewport in both scroll directions while producing the identical serialized geometry (stored coord includes the draw-time scroll, the serialized transform subtracts the submit-time scroll). Also tracks min-width against scrollWidth for horizontally scrollable pages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Hardened after a self-review: the first version anchored the counter-shift to the drawing-start scroll position, which left the top strip of the viewport undrawable (and produced negative, clipped coordinates) if the user scrollbar-dragged above that anchor while marking. The overlay now works in document coordinates with |
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.
Problem
Gleap ticket #141665 (reported by MEINbusiness): a bug-report screenshot showed the customer's marker rectangle around the wrong content. The end user had marked the "Zuschlag" row, but in the rendered screenshot the rectangle sat ~120px lower, around an email address row.
Root cause
The capture editor's annotation SVG (
.bb-capture-svg) isposition: fixedand drawings are stored in viewport coordinates (clientX/clientY). The DOM snapshot is serialized later, at submit time. If the page scrolls between drawing and submit, the snapshot records the new scroll position (bb-scrolltop/snapshotPosition), and the replayed screenshot shows the marks shifted by exactly the scroll delta.Scrolling can happen after drawing because:
GleapScrollStopperblocks wheel/touch/arrow keys but not scrollbar dragging, andVerified against the actual snapshot of the affected ticket: the marker aligns exactly with the intended row once the 120px scroll delta (draw-time scroll 1116 vs. submit-time scroll 1236) is compensated; re-rendered through Server-HTMLtoImage locally to confirm (renderer itself is not at fault).
Fix
ScreenDrawernow records the scroll position at drawing start and counter-shifts the overlay on every window scroll via an inlinetransform: translate(...):destroy()(drawing finished, form open) and is released inGleapMarkerManager.clear().Deliberately not document-anchored at absolute coordinates: the replay layout can compress vs. the user's browser (font metrics), so absolute document coordinates accumulate layout drift from the page top. The scroll-delta transform only compensates the actual scroll movement and inherits none of that (verified empirically against the real snapshot).
Tests
src/ScreenDrawer.test.jscovering transform tracking, coordinate mapping after mid-drawing scroll, disabled tracking for recordings, and tracker lifecycle (4 tests).npm run buildclean.🤖 Generated with Claude Code