Skip to content

Commit

Permalink
Merge pull request #2785 from SUI-Components/feat/MMAA-42852-fix-phot…
Browse files Browse the repository at this point in the history
…o-sorting

feat(components/molecule/photoUploader): force synchronous update
  • Loading branch information
javiauso authored Dec 10, 2024
2 parents 7f44af2 + 4ca1569 commit 8360215
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/molecule/photoUploader/src/PhotosPreview/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {flushSync} from 'react-dom'
import {ReactSortable} from 'react-sortablejs'

import cx from 'classnames'
Expand Down Expand Up @@ -198,7 +199,13 @@ const PhotosPreview = ({
chosenClass={`${THUMB_CLASS_NAME}--chosen`}
tag="ul"
list={files}
setList={setFiles}
setList={(newList, sortable) => {
if (sortable) {
flushSync(() => setFiles(newList))
} else {
setFiles(newList)
}
}}
animation={200}
draggable={`.${THUMB_SORTABLE_CLASS_NAME}`}
onStart={event => _onSortStart(event)}
Expand Down

0 comments on commit 8360215

Please sign in to comment.