mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
Image: fix table cell always deleting last image
This commit is contained in:
@@ -126,9 +126,8 @@ export default function Image_({
|
||||
[value]
|
||||
);
|
||||
|
||||
const handleDelete = (ref: string) => () => {
|
||||
const handleDelete = (index: number) => () => {
|
||||
const newValue = [...value];
|
||||
const index = findIndex(newValue, ["ref", ref]);
|
||||
const toBeDeleted = newValue.splice(index, 1);
|
||||
toBeDeleted.length && deleteUpload(toBeDeleted[0]);
|
||||
onSubmit(newValue);
|
||||
@@ -184,7 +183,7 @@ export default function Image_({
|
||||
>
|
||||
<Grid container spacing={0.5} wrap="nowrap">
|
||||
{Array.isArray(value) &&
|
||||
value.map((file: FileValue) => (
|
||||
value.map((file: FileValue, i) => (
|
||||
<Grid item key={file.downloadURL}>
|
||||
{disabled ? (
|
||||
<Tooltip title="Open">
|
||||
@@ -225,7 +224,7 @@ export default function Image_({
|
||||
body: "This image cannot be recovered after",
|
||||
confirm: "Delete",
|
||||
confirmColor: "error",
|
||||
handleConfirm: handleDelete(file.ref),
|
||||
handleConfirm: handleDelete(i),
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user