fix(browser): avoid dead clicks when changing text selection - #4733
Draft
dustinbyrne wants to merge 1 commit into
Draft
fix(browser): avoid dead clicks when changing text selection#4733dustinbyrne wants to merge 1 commit into
dustinbyrne wants to merge 1 commit into
Conversation
Contributor
Replay incident risk checkThis diff touches code involved in past incidents. This is a heads-up, not a verdict: read the matched sections of INCIDENTS.md and answer their review questions before merging. For a judgment on whether this diff has the same failure mode, run the |
Contributor
Contributor
posthog-js Compliance ReportDate: 2026-09-01 20:55:46 UTC ✅ All Tests Passed!26/26 tests passed Capture Tests✅ 26/26 tests passed View Details
|
Contributor
|
Size Change: +1.2 kB (+0.01%) Total Size: 20.8 MB 📦 View Changed
ℹ️ View Unchanged
|
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
Dead-click detection can report clicks that only clear an existing text selection as
$dead_click. The SDK also listens forselectionchangeonwindow, but document selection events do not bubble there, so real browser events are missed.Fixes #1552.
Changes
selectionchangeondocumentand remove the listener from the same target during teardown.This does not change the public API or
$dead_clickpayload shape. It intentionally reduces default$dead_clickcapture for clicks associated with text selection changes. No new dependencies are added, and the implementation remains in the lazy-loaded dead-click bundle.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset fileValidation
pnpm exec jest src/__tests__/entrypoints/lazy-loaded-dead-clicks-autocapture.test.ts src/__tests__/entrypoints/lazy-loaded-dead-swipes-autocapture.test.ts --runInBand— 100 passed, 1 skippedpnpm exec playwright test playwright/mocked/dead-clicks.spec.ts --project chromium --project firefox --project webkit— 36 passedgit diff --checkpassed🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with Pi Coding Agent under @dustinbyrne's direction. Browser-backed investigation established the actual
selectionchangedelivery and event order across Chromium, Firefox, and WebKit. The final implementation keeps pre-click selection changes suppression-only while retaining existing post-click timeout semantics and repeated-click deduplication. Two fresh read-only agent reviews were completed; their findings were addressed before submission.