Skip to content

fix: Allow disabling default layer provider#424

Merged
MatiPl01 merged 1 commit intomainfrom
feat/allow-disabling-default-layer-provider
Jul 12, 2025
Merged

fix: Allow disabling default layer provider#424
MatiPl01 merged 1 commit intomainfrom
feat/allow-disabling-default-layer-provider

Conversation

@MatiPl01
Copy link
Copy Markdown
Owner

Description

This PR should fix the context menu issue reported in #417. The issue seems to be caused by the zIndex change of the sortable component when the item gets activated, which cancels the long press gesture from the context menu. I haven't found any better solution than this, which lets the user disable the zIndex change and just added a new prop to disable it.

Setting bringToFrontWhenActive to false, unfortunately results in rendering sortable items below its siblings rendered below (after it), which can be seen in the following example.

Source code
import { useCallback } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import type { SortableGridRenderItem } from 'react-native-sortables';
import Sortable from 'react-native-sortables';

import { ScrollScreen } from '@/components';
import { colors, radius, sizes, spacing, text } from '@/theme';

const DATA = Array.from({ length: 5 }, (_, index) => `Item ${index + 1}`);

export default function PlaygroundExample() {
  const renderItem = useCallback<SortableGridRenderItem<string>>(
    ({ item }) => (
      <View style={styles.card}>
        <Text style={styles.text}>{item}</Text>
      </View>
    ),
    []
  );

  return (
    <ScrollScreen contentContainerStyle={styles.container} includeNavBarHeight>
      <Sortable.Grid
        bringToFrontWhenActive={false}
        columnGap={10}
        columns={3}
        data={DATA}
        renderItem={renderItem}
        rowGap={10}
      />
      <Sortable.Grid
        columnGap={10}
        columns={3}
        data={DATA}
        renderItem={renderItem}
        rowGap={10}
      />
    </ScrollScreen>
  );
}

const styles = StyleSheet.create({
  card: {
    alignItems: 'center',
    backgroundColor: '#36877F',
    borderRadius: radius.md,
    height: sizes.xl,
    justifyContent: 'center'
  },
  container: {
    padding: spacing.md
  },
  text: {
    ...text.label2,
    color: colors.white
  }
});
bringToFrontWhenActive={true} bringToFrontWhenActive={false}
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-07-12.at.18.53.12.mp4
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-07-12.at.18.52.48.mp4

@MatiPl01 MatiPl01 self-assigned this Jul 12, 2025
@MatiPl01 MatiPl01 added enhancement New feature or request fix labels Jul 12, 2025
@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
react-native-sortables-docs ⬜️ Ignored (Inspect) Jul 12, 2025 5:03pm

@MatiPl01 MatiPl01 marked this pull request as ready for review July 12, 2025 17:28
@MatiPl01 MatiPl01 merged commit ded5c92 into main Jul 12, 2025
6 checks passed
@MatiPl01 MatiPl01 deleted the feat/allow-disabling-default-layer-provider branch July 12, 2025 17:28
MatiPl01 pushed a commit that referenced this pull request Jul 29, 2025
# [1.8.0](v1.7.1...v1.8.0) (2025-07-29)

### Bug Fixes

* Allow disabling default layer provider ([#424](#424)) ([ded5c92](ded5c92)), closes [#417](#417) [#36877](https://github.com/MatiPl01/react-native-sortables/issues/36877)
* Buggy grid swapping in some edge cases ([#414](#414)) ([3617f86](3617f86))
* DragProvider drag end index assignment ([#411](#411)) ([69ad8a6](69ad8a6))
* Hiding of the sortable item when teleported ([#436](#436)) ([4c3796f](4c3796f))
* Invalid flex container height on initial render and other small issues ([#437](#437)) ([48e905b](48e905b))
* Invalid ScrollView position on input focus ([#431](#431)) ([2693234](2693234)), closes [#ef4444](https://github.com/MatiPl01/react-native-sortables/issues/ef4444)
* Long drop duration reordering issues ([#406](#406)) ([ace7037](ace7037))
* Multiple minor improvements ([#439](#439)) ([f9d83e3](f9d83e3))
* Paper flickering and positioning issues ([#426](#426)) ([744e291](744e291))
* Teleported active item flickering ([#405](#405)) ([1413af2](1413af2))

### Features

* Base multi zone provider ([#409](#409)) ([56f0ef3](56f0ef3))
* Base zone with event callbacks ([#413](#413)) ([e51ca61](e51ca61))
* Fixed items support in sortable flex ([#416](#416)) ([1d23fcc](1d23fcc)), closes [#374](#374)
* Max overscroll settings ([#423](#423)) ([167dc4e](167dc4e)), closes [#419](#419)
* Separate controlled item dimensions from measured dimensions ([#433](#433)) ([cad95e5](cad95e5))

### Performance Improvements

* Merge item decoration styles with position styles ([#407](#407)) ([5066edd](5066edd))
* More performant items reordering ([#435](#435)) ([be78141](be78141))
* Reduce the number of unnecessary onLayout calls ([#434](#434)) ([ce56159](ce56159)), closes [#431](#431)
* Replace useSharedValue with useMutableValue ([#408](#408)) ([6994c7a](6994c7a))
@MatiPl01
Copy link
Copy Markdown
Owner Author

🎉 This issue has been resolved in version 1.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request fix released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant