fix: keep native context menus open when long-pressing sortable items#576
Draft
MatiPl01 wants to merge 1 commit into
Draft
fix: keep native context menus open when long-pressing sortable items#576MatiPl01 wants to merge 1 commit into
MatiPl01 wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
845f44a to
6dd6913
Compare
6dd6913 to
1585f0c
Compare
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.
Closes #417.
Problem
When a
Sortable.Grid/Sortable.Flexitem'srenderItemcontains a native iOS context menu (zeego,@expo/ui,react-native-ios-context-menu- all backed byUIContextMenuInteraction), long pressing the item opens the menu and then immediately dismisses it.Root cause: on long press the sortable activates a drag and elevates the item's
zIndex(per item viauseItemZIndex, and the container via the layer provider). When the native menu commits it cancels the gesture,handleDragEndresets thezIndex, and that stacking context change on an ancestor of the menu's view dismisses the menu. SettingbringToFrontWhenActive: falsedid not help, because the per itemzIndexstill elevated and reset.Fix
Defer every "bring to front"
zIndexchange until the item is actually dragged. A plain long press no longer changes anyzIndex, so the native menu is never dismissed, while a real drag elevates exactly as before. The fix is library agnostic: it only changes WHEN the sortable mutateszIndex, nothing context menu specific.The "is it a drag yet" check reuses the existing
dragActivationFailOffset(the offset already used to tell a scroll from a drag) instead of a new threshold.Verification
useItemZIndex: no elevation during a long press, identical elevation once the item is dragged.react-native-ios-context-menuwrapping each grid item, dragging still reorders correctly, and the menu was observed opening and staying with the fix.The fix removes the exact thing the issue diagnoses as the cause (the long press
zIndexchange), so a native menu that opens on long press is no longer dismissed by it.