Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components/molecule/photoUploader): force synchronous update #2785

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

codemaoz90
Copy link
Collaborator

@codemaoz90 codemaoz90 commented Dec 9, 2024

Category/Component

❓Ask

TASK: MMAA-42852

Description, Motivation and Context

In the PhotosPreview component, we use ReactSortable to enable drag-and-drop functionality for a list of photos. However, with the introduction of automatic batching in React 18, state updates may not reflect immediately

To fix this issue, we use flushSync from react-dom to force a synchronous state update when sortable is true and with this have the list state updated and sorted

I followed this suggestion: SortableJS/react-sortablejs#263 (comment)

Types of changes

  • 🪲 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🧾 Documentation
  • 📷 Demo
  • 🧪 Test
  • 🧠 Refactor
  • 💄 Styles
  • 🛠️ Tool

Screenshots - Animations

Copy link

github-actions bot commented Dec 9, 2024

STATEMENTS BRANCHES FUNCTIONS LINES
≍ 0.07↓ ≍ 0.04↓ ≍ 0.13↓ ≍ 0.13↓
% 75.87 64.06 65.6 77.65
ABS 3378 / 4452 2073 / 3236 658 / 1003 3197 / 4117

@javiauso javiauso merged commit 8360215 into master Dec 10, 2024
7 checks passed
@javiauso javiauso deleted the feat/MMAA-42852-fix-photo-sorting branch December 10, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants