Skip to content

chaning zIndex cancels pan and onFinalize and onDeactivate not guarranteed #4320

Description

@voxlz

Description

Scenario: I have a multi-choice drag and drop screen. I want the currently dragged choice to be on top, so i set its zIndex higher on dragStart. This sometimes results in other drags getting canceled and onFinalize and onDeactivate to never trigger, breaking UI.

Two issues:

  1. According to the docs:
    `Note that some of these callbacks are complementary:

if onBegin was called, it is guaranteed that onFinalize will be called later.
if onActivate was called, it is guaranteed that onDeactivate will be called later.
`
This is no longer true as zIndex changes sometimes drop them when gesture gets cancelled.

  1. There is no reason the gesture should get canceled since the zIndex change did not actually affect the drag in any way, nothing rendered between finger and draggable.

Steps to reproduce

  1. Open reproduction
  2. try dragging one or both boxes around. The automated zIndex swap will cancel the drag unnexpectabily.
  3. Spam click and drag around a bit. Over time you can see in the stats that begin and finalize drift, as well as activate vs deactivate.
ScreenRecording_07-18-2026.18-39-41_1.MP4

A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.

https://github.com/voxlz/rngh-zindex-swap-repro

Gesture Handler version

3.1.0

React Native version

0.86.0

Platforms

iOS

JavaScript runtime

None

Workflow

Using Expo Prebuild or an Expo development build

Architecture

New Architecture (Fabric)

Build type

Debug mode

Device

Real device

Device model

iPhone 13

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform: iOSThis issue is specific to iOSRepro providedA reproduction with a snack or repo is provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions