Skip to content

Conversation

@MatiPl01
Copy link
Owner

@MatiPl01 MatiPl01 commented Aug 10, 2025

Description

Base support for collapsible items - adds auto adjustment of the content position to manage the active item position unchanged when other items collapse (reduce their size).

Example recording

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-08-19.at.15.18.26.mp4

@MatiPl01 MatiPl01 self-assigned this Aug 10, 2025
@vercel
Copy link

vercel bot commented Aug 10, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
react-native-sortables-docs Ignored Ignored Preview Aug 19, 2025 1:26pm

@MatiPl01
Copy link
Owner Author

Current state

Something works but many things are still hardcoded and not perfect:

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-08-13.at.10.30.34.mp4

@MatiPl01 MatiPl01 force-pushed the feat/collapsible-items branch from ef4a06a to 5b2f7f7 Compare August 18, 2025 01:58
@MatiPl01 MatiPl01 marked this pull request as ready for review August 19, 2025 13:05
@MatiPl01
Copy link
Owner Author

This PR is quite large so I decided to merge it and improve remaining things later on.

TODO

  1. Proper support for auto scroll
  2. Proper support for portal case
  3. Fixing content jumps when container height changes inside the scrollview

@MatiPl01 MatiPl01 requested a review from Copilot August 19, 2025 13:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for collapsible items in the react-native-sortables library. The changes enable items to dynamically change their dimensions during drag operations while maintaining proper layout calculations and positioning.

  • Refactored type names from ControlledSizes to ItemSizes for better clarity
  • Implemented automatic cross-axis offset calculation for grid layouts when items resize during drag
  • Enhanced debounce utility with cancel functionality and improved measurement batching

Reviewed Changes

Copilot reviewed 43 out of 44 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/react-native-sortables/src/utils/misc.ts Reformatted isPresent function to arrow function style
packages/react-native-sortables/src/utils/layout.ts Added calculateSnapOffset utility function
packages/react-native-sortables/src/utils/dimensions.ts Renamed ControlledSizes type to ItemSizes
packages/react-native-sortables/src/types/layout/shared.ts Updated type name from ControlledSizes to ItemSizes
packages/react-native-sortables/src/types/providers/shared.ts Added triggerOriginPosition to DragContextType
packages/react-native-sortables/src/types/providers/grid.ts Added new grid-specific context types
packages/react-native-sortables/src/types/providers/flex.ts Removed grid layout types (moved to separate file)
packages/react-native-sortables/src/types/props/grid.ts Added autoAdjustOnResizeDuringDrag prop
packages/react-native-sortables/src/providers/shared/hooks/useOrderUpdater.ts Refactored to accept strategy factory and predefined strategies
packages/react-native-sortables/src/providers/shared/hooks/useItemLayoutStyle.ts Updated debounce usage to new API
packages/react-native-sortables/src/providers/shared/MeasurementsProvider.ts Enhanced measurement batching and dimension updating logic
packages/react-native-sortables/src/providers/shared/DragProvider.ts Added trigger origin position calculation and snap offset logic
packages/react-native-sortables/src/providers/grid/AdditionalCrossOffsetProvider.tsx New provider for calculating cross-axis offsets during item resizing
packages/react-native-sortables/src/providers/grid/layout/utils/layout.ts Added cross offset calculation functions for grid layouts
packages/react-native-sortables/src/integrations/reanimated/hooks/useAnimatedDebounce.ts Enhanced debounce with cancel functionality
example/app/src/examples/SortableGrid/miscellaneous/CollapsibleItemsExample.tsx Added example demonstrating collapsible items functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

MatiPl01 and others added 5 commits August 19, 2025 15:11
…dleProvider.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ntsProvider.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@MatiPl01 MatiPl01 merged commit 66c03b6 into main Aug 19, 2025
6 checks passed
@MatiPl01 MatiPl01 deleted the feat/collapsible-items branch August 19, 2025 13:26
MatiPl01 added a commit that referenced this pull request Sep 8, 2025
## Description

This PR is a huge improvement over the initial collapsible items
implementation introduced in the #444 PR. It re-implements the core
logic so that updates are performed synchronously with layout changes,
thanks to which there are far less glitches and unexpected actions.

It also implements a smart way of scroll offset restoration after items
expand to their normal positions.

## Changes showcase


https://github.com/user-attachments/assets/2cb3ab86-d6a5-412b-b46e-6f2e80a2152e

## TODO

- [x] Fix horizontal collapsible items layout positions animation after
collapse
- [x] Test if it works on Paper
MatiPl01 pushed a commit that referenced this pull request Sep 13, 2025
# [1.9.0](v1.8.0...v1.9.0) (2025-09-13)

### Bug Fixes

* A bunch of issues, like shaky scroll, invalid grid layout, added items flickering ([#463](#463)) ([3b160b6](3b160b6))
* Active item touch start position on Android ([#462](#462)) ([7704729](7704729))
* Autoscroll exceeding bounds ([#473](#473)) ([eddd21b](eddd21b))
* Collapsible items implementation on the web ([#485](#485)) ([4d261db](4d261db))
* Collapsible items shift when size changes ([#451](#451)) ([e816b6a](e816b6a))
* Incorrect drag start position, no item size animation when teleported ([#456](#456)) ([1730fb8](1730fb8))
* Invalid builder bob config ([#475](#475)) ([11cf84a](11cf84a))
* Invalid grid layout on mount ([#461](#461)) ([a47ed72](a47ed72))
* onActiveItemDropped not being fired when item is touched quickly ([#449](#449)) ([f66d980](f66d980))
* Pre-release fixes and improvements ([#476](#476)) ([736fb7b](736fb7b))
* Prevent auto scroll from over scrolling content container ([#484](#484)) ([db586d7](db586d7)), closes [#473](#473)

### Features

* Add custom shadow example to docs, clean up decoration style ([#466](#466)) ([1169928](1169928))
* Add example app build check CIs ([#480](#480)) ([5ad420c](5ad420c))
* Add style property to the handle component ([#477](#477)) ([28c9099](28c9099))
* Better collapsible auto-scroll behavior ([#457](#457)) ([2d24b14](2d24b14)), closes [#444](#444)
* Collapsible items support ([#444](#444)) ([66c03b6](66c03b6))
* Data provider ([#472](#472)) ([5dc34b6](5dc34b6))
* Improved teleported items behavior ([#452](#452)) ([72dadef](72dadef))
* Make layout update in sync with positions change on grid columns change ([#441](#441)) ([ef37d8c](ef37d8c))
* New auto scroll implementation ([#454](#454)) ([c4facec](c4facec)), closes [#285](#285) [#453](#453) [#285](#285)

### Performance Improvements

* Optimize rerenders caused by inlined callbacks, clean up drag state management ([#474](#474)) ([f5e3c89](f5e3c89))
* Reduce the number of layout calculations ([#442](#442)) ([f9c9875](f9c9875))
@MatiPl01
Copy link
Owner Author

🎉 This issue has been resolved in version 1.9.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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants