Skip to content

fix: reset DraxHandleContext in HoverLayer for nested providers - #303

Open
ottob wants to merge 1 commit into
nuclearpasta:mainfrom
ottob:fix/reset-drax-handle-context-in-hover-layer
Open

ottob wants to merge 1 commit into
nuclearpasta:mainfrom
ottob:fix/reset-drax-handle-context-in-hover-layer

Conversation

@ottob

@ottob ottob commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Wraps HoverLayer content in <DraxHandleContext.Provider value={null}> so any DraxHandle rendered inside a hover clone always sees ctx === null and renders as a plain view without a GestureDetector.
  • In a single DraxProvider, HoverLayer is a sibling outside the dragged DraxView's DraxHandleContext.Provider. However, when a nested DraxProvider (e.g., an inner sortable list) is rendered inside an outer <DraxView dragHandle>, the nested HoverLayer is a descendant of the outer DraxHandleContext.Provider.
  • Dragging an item in the inner DraxProvider clones its children (including its <DraxHandle>) into the inner HoverLayer, which otherwise inherits the outer DraxView's gesture instance from context and crashes react-native-gesture-handler with:
    [react-native-gesture-handler] Using the same gesture instance across multiple GestureDetectors is not possible. Create a separate gesture for each detector.

@vercel

vercel Bot commented Oct 30, 2026

Copy link
Copy Markdown

@ottob is attempting to deploy a commit to the Nuclear Pasta Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs-site Ready Ready Preview Oct 31, 2026 3:12pm UTC
drax-example Ready Ready Preview Oct 31, 2026 3:12pm UTC

@LunatiqueCoder LunatiqueCoder left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 posted by [drax] Reviewer, Ovidiu's review bot

thanks ottob, nice catch! I reproduced this on main before testing the fix.

repro on main: I built a temporary screen with a DraxProvider nested inside a dragHandle DraxView, each with its own DraxHandle. When you drag an inner item, its hover copy's DraxHandle picks up the outer view's gesture (a probe showed the outer gesture tag in the inner hover). Once that hover unmounts, the outer grip stops starting drags. It fails silently, with no error or log, until the screen remounts. The counters ended at outer 1 | inner 1 after three attempts.

on this branch: the hover DraxHandle sees a null context and renders as a plain view. outer → inner → outer → inner → outer all registered (outer 3 | inner 2).

I also dragged items on the reorderable list, drag handles and color drag & drop screens and saw no regressions. yarn typecheck and yarn lint pass, and there are no unit tests in the repo yet.

a few non-blocking notes:

  • the comment at src/DraxHandle.tsx:35-38 says hover content sits outside the handle context tree. after this PR, that's guaranteed by the explicit reset in HoverLayer, so it'd be nice to point there.
  • the same inheritance probably applies to SortableBoardContext / SortableItemContext in a nested provider's hover (for example, a SortableContainer in hover content could auto-register with an outer board). I didn't test that, and it's fine as a follow-up.

Comment thread src/HoverLayer.tsx
>
<Reanimated.View style={[styles.content, dimensionStyle, visualStyle]}>
{hoverContentRef.current}
<DraxHandleContext.Provider value={null}>

@LunatiqueCoder LunatiqueCoder Nov 2, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 posted by [drax] Reviewer, Ovidiu's review bot

verified on iOS: on main, after one drag inside a nested provider, the outer DraxHandle no longer drags; with this it keeps working. could you add a one-line comment here explaining why? something like: hover content must not inherit a parent DraxView's DraxHandleContext, otherwise a DraxHandle in the hover copy attaches the parent's gesture to a second GestureDetector and the parent's handle goes dead after the hover unmounts.

This branch was successfully deployed

2 active deployments
Preview – drax-example — f2be590d Deployed Oct 31, 2026 by vercel[bot]
Preview – docs-site — f2be590d Deployed Oct 31, 2026 by vercel[bot]
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.

2 participants