Skip to content

fix: Item measurements lost when the sortable is hidden with Activity - #644

Draft
MatiPl01 wants to merge 3 commits into
mainfrom
fix/keep-measurements-when-hidden
Draft

MatiPl01 wants to merge 3 commits into
mainfrom
fix/keep-measurements-when-hidden

Conversation

@MatiPl01

@MatiPl01 MatiPl01 commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Description

Each item removes its measurements in an effect cleanup. React also runs effect cleanups when it only hides a tree, for example with <Activity mode='hidden'>. The items keep their size while hidden and do not report their layout again when they are shown, so nothing restored the measurements: after hiding and showing a sortable its layout stopped updating and items could not be dragged any more.

The measurements are now removed only for items that are no longer rendered. This also means that a change of the cleanup dependencies can no longer wipe the measurements of mounted items. An item for which renderItem returns undefined is stored as null, so that it is not taken for one that is no longer rendered.

Testing

New jest tests with <Activity> (the three hide and show cases fail on main, where all measurements are gone). Adding, removing and dragging items in the Data Change example still works on the iOS simulator (Fabric).

Evidence
Tests on main before-tests-on-main.txt
Tests with the fix after-tests-with-fix.txt

The cleanup that removes the measurements of an item also runs when React only hides the tree (Activity). The item does not report its layout again when it is shown, so nothing restored the measurements: the layout stopped updating and items could not be dragged. The measurements are now removed only for items that are no longer rendered.
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
react-native-sortables-docs Ignored Ignored Preview Nov 26, 2026 3:54pm UTC

@MatiPl01 MatiPl01 self-assigned this Nov 25, 2026
Also covers an item added after the sortable is hidden and shown again, measured through its onLayout.

This branch has not been deployed

No deployments
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.

1 participant