Skip to content

Conversation

@daniel-graham-amplitude
Copy link
Collaborator

@daniel-graham-amplitude daniel-graham-amplitude commented Jan 3, 2026

Summary

Cancel a rage click if there is a text highlight event that happens after a click.

If a user clicks 1 or more times, and then text is highlighted, that suggests that the user's clicks caused the text to be highlighted

Here's a demonstration to show if you highlight text in an input, the first 3 clicks cause the text to be highlighted, which cancels out the rage click. You thus need at least 7 clicks for it to be a rage click (4 clicks after the text is done being highlighted).

Screen.Recording.2026-01-02.at.5.41.11.PM.mov

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: No

Note

Prevents rage-click events when user text selection occurs by integrating a new observable and resetting detection state.

  • Adds SelectionObservable to AllWindowObservables and wires it in frustration-plugin via document.selectionchange (handles inputs/textareas and generic selections)
  • Updates track-rage-click to subscribe to selectionObservable and resetClickWindow() on selection; returns a composite subscription that unsubscribes both click and selection listeners
  • Extends interfaces/enums (ObservablesEnum) to include selectionObservable
  • Adds tests for selection observable behavior and rage-click cancellation/continuation logic in frustration-plugin.test.ts and track-rage-click.test.ts

Written by Cursor Bugbot for commit 9eb5742. This will update automatically on new commits. Configure here.

 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
This reverts commit db34376.
…cript into AMP-146045-rage-click-fix-mobile-scroll-false-positive
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
 - @amplitude/[email protected]
@daniel-graham-amplitude daniel-graham-amplitude marked this pull request as draft January 3, 2026 00:27
@daniel-graham-amplitude daniel-graham-amplitude changed the title Amp 146044 fix highlightable text rage clicks fix(plugin-autocapture-browser): do not trigger rage click when text being highlighted Jan 3, 2026
Comment on lines +201 to +205
unsubscribe: () => {
rageClickSubscription.unsubscribe();
/* istanbul ignore next */
selectionSubscription?.unsubscribe();
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending rage‑click timeout isn’t cleared, so it can fire after teardown or a window reset and emit unexpectedly. Suggest always cancel and null any pending rageClick timer during teardown and whenever the click window is reset.

Suggested change
unsubscribe: () => {
rageClickSubscription.unsubscribe();
/* istanbul ignore next */
selectionSubscription?.unsubscribe();
},
unsubscribe: () => {
if (pendingRageClick) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
clearTimeout(pendingRageClick.timerId);
pendingRageClick = null;
}
rageClickSubscription.unsubscribe();
/* istanbul ignore next */
selectionSubscription?.unsubscribe();
},

🚀 Want me to fix this? Reply ex: "fix it for me".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, this was here before. It just means that if it's unsubscribed and a rage click happens within the short window after unsubscribing, it will fire off one last event.

@daniel-graham-amplitude daniel-graham-amplitude force-pushed the AMP-146045-rage-click-fix-mobile-scroll-false-positive branch from 3696ef2 to 2f9f9a5 Compare January 5, 2026 17:34
… of github.com:amplitude/Amplitude-TypeScript into AMP-146044-fix-highlightable-text-rage-clicks
… AMP-146045-rage-click-fix-mobile-scroll-false-positive
… of github.com:amplitude/Amplitude-TypeScript into AMP-146044-fix-highlightable-text-rage-clicks
Base automatically changed from AMP-146045-rage-click-fix-mobile-scroll-false-positive to main January 5, 2026 22:37
@daniel-graham-amplitude daniel-graham-amplitude marked this pull request as ready for review January 5, 2026 22:37
… AMP-146044-fix-highlightable-text-rage-clicks
@promptless
Copy link

promptless bot commented Jan 5, 2026

📝 Documentation updates detected!

New suggestion: Document rage click text selection behavior

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.

4 participants