fix: additional check for touch event before calling preventDefault#138
Merged
mattlewis92 merged 1 commit intomainfrom Mar 12, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #138 +/- ##
==========================================
- Coverage 81.27% 81.20% -0.07%
==========================================
Files 6 6
Lines 283 282 -1
Branches 61 59 -2
==========================================
- Hits 230 229 -1
Misses 42 42
Partials 11 11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mattlewis92
reviewed
Mar 12, 2026
| ).pipe( | ||
| tap(({ event }) => { | ||
| if (currentResize && event.cancelable) { | ||
| if (currentResize && event.cancelable && !isTouchEvent(event)) { |
Owner
There was a problem hiding this comment.
Isn't this what event.cancelable is meant to do?
https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable
Collaborator
Author
There was a problem hiding this comment.
event.cancelable tells us if the event can be cancelled or not, but the touchEvent check is due to https://chromestatus.com/feature/5093566007214080 which now treats touch events as passive and we shouldn't be calling preventDefault on these even if they are cancelable.
mattlewis92
approved these changes
Mar 12, 2026
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
Only call
event.preventDefault()for mouse events. For touch events we no longer call it, so touch listeners can stay passive and browsers don’t warn about non-passive listeners.Changes
isTouchEvent()utility (util/is-touch-event.ts)event.type.startsWith('touch').Resize handle (
resize-handle.directive.ts)onMousedown, call preventDefault() only when the event is cancelable and not a touch event:if (event.cancelable && !isTouchEvent(event)) { event.preventDefault(); }Resizable (
resizable.directive.ts)Removed
util/get-listen-options.tsTests (
resizable.spec.ts)Result
Touch resize/drag no longer triggers “passive event listener” warnings while mouse behavior (and preventDefault for mouse when needed) is unchanged.