From 14fd59c4d0d787557363212b9e4684fc975345d2 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 21 May 2023 09:54:24 +0200 Subject: [PATCH] Stop trying to sort the attachments in the sidebar Looking at the behaviour in Adobe Reader it doesn't appear that attachments are sorted alphabetically, hence it doesn't seem necessary for us to do so either in the viewer. An additional benefit of *not* sorting the attachments is that any "actual" attachments are now always placed at the top of the list in the sidebar, and if any `FileAttachment`-annotations exist in the document they will now be appended at the end. --- web/pdf_attachment_viewer.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/web/pdf_attachment_viewer.js b/web/pdf_attachment_viewer.js index be8588878..49b27dd47 100644 --- a/web/pdf_attachment_viewer.js +++ b/web/pdf_attachment_viewer.js @@ -109,13 +109,10 @@ class PDFAttachmentViewer extends BaseTreeViewer { this._dispatchEvent(/* attachmentsCount = */ 0); return; } - const names = Object.keys(attachments).sort(function (a, b) { - return a.toLowerCase().localeCompare(b.toLowerCase()); - }); const fragment = document.createDocumentFragment(); let attachmentsCount = 0; - for (const name of names) { + for (const name in attachments) { const item = attachments[name]; const content = item.content, filename = getFilenameFromUrl(