Skip to content

Fix document handler cleanup for cancelled and unmounted slider interactions - #330

Draft
hexmarkrecords wants to merge 2 commits into
zillow:masterfrom
hexmarkrecords:master
Draft

hexmarkrecords wants to merge 2 commits into
zillow:masterfrom
hexmarkrecords:master

Conversation

@hexmarkrecords

Copy link
Copy Markdown

Summary

Fixes cleanup of document-level interaction handlers when a slider interaction is interrupted.

  • Removes active mouse, touch, and keyboard handlers in componentWillUnmount.
  • Adds touchcancel support and cleans up active touch handlers when it fires.
  • Calls preventDefault() for touchend only when the event is cancelable.

Why

The slider registers document-level handlers while an interaction is active. If the component unmounts before the usual end event, those handlers were not removed. Touch interactions can also be interrupted without a touchend event.

This change ensures handlers are cleaned up in both cases without changing normal slider behavior.

Tests

Added coverage for:

  • Removing touch handlers after touchcancel.
  • Avoiding preventDefault() for non-cancelable touchend events.
  • Removing active mouse, touch, and keyboard handlers when the component unmounts.

Verification

  • npm test -- --runInBand src/components/ReactSlider/__tests__/ReactSlider.test.js
  • npm run eslint -- --no-fix

hexmarkrecords and others added 2 commits September 14, 2026 19:19
…tive-document-handlers-on-unmount-and-handle-touch-cancellation

fix(react-slider): clean up document handlers on interrupted touch drags
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.

1 participant