From c97f0f4b62aca4e1a5166ed8761aa727d0960acd Mon Sep 17 00:00:00 2001 From: Mike <36415632+Mike-Heneghan@users.noreply.github.com> Date: Fri, 27 Oct 2023 09:16:56 +0100 Subject: [PATCH] feat: first pass reordering uploaded files to show most recent first (#2335) * feat: order file uploads slots by most recent - As per Jess's comment: https://github.com/theopensystemslab/planx-new/pull/2335#pullrequestreview-1692357713 - Small change to flip the ordering of slots so that the most recently uploaded file is at the top --- .../src/@planx/components/FileUploadAndLabel/Public.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.tsx b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.tsx index 6ef543884e..87decf9a4e 100644 --- a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.tsx +++ b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.tsx @@ -94,6 +94,10 @@ function Component(props: Props) { const previousSlotCount = usePrevious(slots.length); useEffect(() => { if (previousSlotCount === undefined) return; + + // Show most recent upload at the top + if (slots.length) setSlots(slots.reverse()); + // Only stop modal opening on initial return to node if (isUserReturningToNode) return setIsUserReturningToNode(false); if (slots.length && dropzoneError) setDropzoneError(undefined);