Hello,
I am trying to display a list of images with buttons that delete them when clicked. I'm using the Upload component and utilizing the 'listItemUI' attribute and it works wonderfully. However, I am trying to reverse the order of the elements displayed so that the most recent is at the top and the least recent is at the bottom.
CustomListItemUI(e) {
return (
<ul id="custom-list-item-UL">
{e.files.map((el, index) => {
if (el.Thumbnail_URL) {
return (
<li
className="k-file"
key={index}
>
<div className="k-file-single">
<img src={el.Thumbnail_URL} onClick={() => this.toggleDialog(el)} />
</div>
<button
type="button"
onClick={async () => {
this.actualUploader.current.onRemove(el.uid);
await this.props.deleteImage(el.ID);
}}
tabIndex="-1"
>
<span aria-label="Remove" title="Remove" className="k-icon k-i-delete">
</span>
</button>
</li>
);
} else {
return (
<li key={index}>
<Loader errorsPresent={el.validationErrors} />
{
el.ID || el.validationErrors?.length >= 0 ? <button
type="button"
onClick={async () => {
this.actualUploader.current.onRemove(el.uid);
}}
tabIndex="-1"
>
<span aria-label="Remove" title="Remove" className="k-icon k-i-delete">
</span>
</button>
: null
}
</li>
);
}
})
}
</ul>
);
}
I have tried sorting the data that goes into the <ul> and it doesn't make a difference.
I have tried putting display: flex, and flex-direction: column-reverse, and this works but places the scroller at the bottom with the most early upload (which is also not what I want). Is there some kind of sorting attribute or method I can use to achieve what I want?