Repository navigation
Undo a cancelled ReanimatedDrawerLayout pan - #4635
mkantautas wants to merge 1 commit into
Conversation
A pan that is cancelled or fails after it activated still runs the release logic, so a drawer dragged past half of its width opens (or closes) and fires onDrawerOpen (or onDrawerClose). Settle the drawer where it rested before the gesture instead, the same way ReanimatedSwipeable handles a cancelled pan.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
🟢 Approval recommended
The narrowly scoped fix preserves the existing animation lifecycle and has targeted regression coverage, with no blocking issues identified.
No open issues 🎉
What changed in this PR
Updates ReanimatedDrawerLayout to restore its current open or closed state when an active pan is cancelled or fails, instead of treating it as a normal release.
Changes:
- Handles cancelled releases through the existing drawer animation and callback lifecycle.
- Adds regression tests for normal release and cancellation or failure from both open and closed states.
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx | Restores the drawer’s resting state on cancelled releases. |
| packages/react-native-gesture-handler/src/__tests__/reanimatedDrawerLayoutRelease.test.tsx | Tests release behavior, restored positions, and state callbacks. |
Review effort: Balanced
Description
ReanimatedDrawerLayoutpasses its pan'sonDeactivatetohandleRelease, which does not readevent.canceled. When the pan is cancelled or fails after it activated (on web, for example, when the browser sendspointercancel), the drawer settles from the last translation and velocity as if the finger had lifted. A closed drawer dragged past half of its width opens and callsonDrawerOpen, and an open drawer dragged past half of its width closes and callsonDrawerClose.handleReleasenow settles a cancelled release at the drawer's current open or closed state instead of projecting the drag. This is the cancellation handling #4618 added toReanimatedSwipeable.The restore goes through
animateDrawer, soonDrawerStateChangedstill ends inIDLEand the callback for the resting position fires, as it does after a release that does not cross half of the width.Test plan
New Jest tests in
reanimatedDrawerLayoutRelease.test.tsxdrive the pan throughcreateGestureController: a pan that ends past half of the width opens the drawer, and a cancelled or failed pan past half keeps a closed drawer closed and an open drawer open. The four cancel and fail cases fail onmain.Web,
apps/expo-example"Reanimated Drawer Layout" screen in Chromium with touch input sent over CDP (Input.dispatchTouchEvent):maintouchCanceltouchCanceltouchEndtouchCancelyarn test(24 suites, 238 tests),yarn ts-check,yarn lint-jsandyarn circular-dependency-checkpass inpackages/react-native-gesture-handler.Not run on Android or iOS.