Skip to content

Commit

Permalink
fix: use index for deleting asset [ZEND-5025] (#7932)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitelisab authored Jun 3, 2024
1 parent ce78780 commit af76064
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/dam-app-base/src/Editor/SortableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ export const SortableComponent = ({
const [items, setItems] = useState<AssetWithId[]>([]);

const deleteItem = useCallback(
(index: UniqueIdentifier) => {
(index: number) => {
const myResources = [...resources];
myResources.splice(Number(index), 1);
myResources.splice(index, 1);
onChange(myResources);
},
[resources]
[resources, onChange]
);

useEffect(() => {
Expand Down Expand Up @@ -313,14 +313,14 @@ export const SortableComponent = ({
<SortableContext items={items?.map((i) => i.key)} strategy={verticalListSortingStrategy}>
<div className={styles.container} data-testid="container">
<div className={styles.grid} data-testid="grid">
{items.map(({ key, alt, url, additionalData }) => (
{items.map(({ key, alt, url, additionalData }, index) => (
<div key={key}>
<SortableItem
disabled={disabled}
url={url}
alt={alt}
uniqueId={key}
onDelete={() => deleteItem(key)}
onDelete={() => deleteItem(index)}
additionalData={additionalData}
/>
</div>
Expand Down

0 comments on commit af76064

Please sign in to comment.