Skip to content

fix: Teleported active item flickering#405

Merged
MatiPl01 merged 5 commits intomainfrom
fix/teleported-item-flickering
Jun 19, 2025
Merged

fix: Teleported active item flickering#405
MatiPl01 merged 5 commits intomainfrom
fix/teleported-item-flickering

Conversation

@MatiPl01
Copy link
Copy Markdown
Owner

Description

Describe what was changed in this pull request

Changes showcase

Include example images/recordings if the new feature introduces some
visual changes or the PR fixes a UI bug

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

vercel Bot commented Jun 19, 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) Visit Preview Jun 19, 2025 10:27pm

@MatiPl01 MatiPl01 requested a review from Copilot June 19, 2025 22:18
Copy link
Copy Markdown
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 refactors the teleport mechanism to eliminate flicker by introducing outlet measurements, deriving absolute positions in a single hook, and managing teleport state in the draggable view.

  • Streamlines the portal API by removing subscriptions and using a shared outlet measurement.
  • Simplifies useTeleportedItemStyles to compute absolute positions via useDerivedValue.
  • Updates DraggableView and ActiveItemPortal to track and hide the original item during teleport.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/react-native-sortables/src/types/providers/shared.ts Removed subscription API and replaced portal outlet ref with a measurement value.
packages/react-native-sortables/src/providers/shared/hooks/useTeleportedItemStyles.ts Refactored animation logic into a single derived value for absolute positioning.
packages/react-native-sortables/src/providers/shared/hooks/useItemLayoutStyles.ts Renamed and unified hidden style for items without initial translation.
packages/react-native-sortables/src/providers/shared/hooks/useItemDecorationStyles.ts Dropped teleport-state branches to streamline decoration animations.
packages/react-native-sortables/src/providers/shared/PortalProvider.tsx Eliminated subscriber lists; simplified teleport state management.
packages/react-native-sortables/src/providers/shared/PortalOutletProvider.tsx Added outlet measurement via onLayout and stored it in a shared value.
packages/react-native-sortables/src/components/shared/DraggableView/TeleportedItemCell.tsx Removed render notifications; teleported items now render directly.
packages/react-native-sortables/src/components/shared/DraggableView/ItemCell.tsx Made measurement callback optional and cleaned up layout event handling.
packages/react-native-sortables/src/components/shared/DraggableView/DraggableView.tsx Introduced isTeleported state, hid original item while active, updated teleport logic.
packages/react-native-sortables/src/components/shared/DraggableView/ActiveItemPortal.tsx Replaced subscription-based teleport with useAnimatedReaction and JS-run callbacks.
packages/react-native-sortables/src/components/shared/AnimatedOnLayoutView.tsx Renamed for clarity and standardized the onLayout prop in the web wrapper.
Comments suppressed due to low confidence (2)

packages/react-native-sortables/src/components/shared/DraggableView/ActiveItemPortal.tsx:13

  • The portal node isn’t being cleaned up if the component unmounts while still teleported. Add a cleanup useEffect (returning a cleanup function) to disable the teleport (e.g., call disableTeleport) on unmount to prevent orphaned nodes in the outlet.
  activationAnimationProgress: SharedValue<number>;

packages/react-native-sortables/src/components/shared/DraggableView/ActiveItemPortal.tsx:47

  • [nitpick] Consider adding unit tests for the teleport lifecycle (activation, update, deactivation, and unmount) in ActiveItemPortal to ensure that nodes are mounted and cleaned up correctly.
  useAnimatedReaction(

Comment thread packages/react-native-sortables/src/providers/shared/PortalProvider.tsx Outdated
…vider.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@MatiPl01 MatiPl01 marked this pull request as ready for review June 19, 2025 22:30
@MatiPl01 MatiPl01 merged commit 1413af2 into main Jun 19, 2025
6 checks passed
@MatiPl01 MatiPl01 deleted the fix/teleported-item-flickering branch June 19, 2025 22:30
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.

2 participants