#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
Fix move button on multitool (#6291)
Reece Browneed56490f93e6
diff --git a/.gitignore b/.gitignoreindex 9b1dba0c65..b10c6cdc3e 100644--- a/.gitignore+++ b/.gitignore@@ -266,3 +266,7 @@ docs/type3/signatures/# Claude.claude/++# Playwright MCP screenshots / traces+.playwright-mcp/+*.playwright-mcp.pngdiff --git a/frontend/src/core/components/pageEditor/PageThumbnail.tsx b/frontend/src/core/components/pageEditor/PageThumbnail.tsxindex 189bdac01c..da54602d81 100644--- a/frontend/src/core/components/pageEditor/PageThumbnail.tsx+++ b/frontend/src/core/components/pageEditor/PageThumbnail.tsx@@ -88,7 +88,6 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({onTogglePage,onExecuteCommand,onSetStatus,- onSetMovingPage,onDeletePage,createRotateCommand,createSplitCommand,@@ -328,10 +327,8 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({label: "Move Left",onClick: (e) => {e.stopPropagation();- if (pageIndex > 0 && !movingPage && !isAnimating) {- onSetMovingPage(page.pageNumber);+ if (pageIndex > 0 && !isAnimating) {onReorderPages(page.pageNumber, pageIndex - 1);- setTimeout(() => onSetMovingPage(null), 650);onSetStatus(`Moved page ${page.pageNumber} left`);}},@@ -343,13 +340,9 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({label: "Move Right",onClick: (e) => {e.stopPropagation();- if (pageIndex < totalPages - 1 && !movingPage && !isAnimating) {- onSetMovingPage(page.pageNumber);- // ReorderPagesCommand expects target index relative to the original array.- // When moving toward the right (higher index), provide desiredIndex + 1- // so the command's internal adjustment (targetIndex - 1) lands correctly.+ if (pageIndex < totalPages - 1 && !isAnimating) {+ // +2 compensates for ReorderPagesCommand's internal targetIndex - 1 adjustment.onReorderPages(page.pageNumber, pageIndex + 2);- setTimeout(() => onSetMovingPage(null), 650);onSetStatus(`Moved page ${page.pageNumber} right`);}},@@ -391,7 +384,6 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({[pageIndex,totalPages,- movingPage,isAnimating,page.pageNumber,handleRotateLeft,@@ -400,7 +392,6 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({handleSplit,handleInsertFileAfter,onReorderPages,- onSetMovingPage,onSetStatus,],);diff --git a/frontend/src/core/components/pageEditor/commands/pageCommands.ts b/frontend/src/core/components/pageEditor/commands/pageCommands.tsindex 402977c46a..1f80b940cd 100644--- a/frontend/src/core/components/pageEditor/commands/pageCommands.ts+++ b/frontend/src/core/components/pageEditor/commands/pageCommands.ts@@ -232,7 +232,7 @@ export class ReorderPagesCommand extends DOMCommand {);if (sourceIndex === -1) return;- const newPages = [...currentDoc.pages];+ let reorderedPages: PDFPage[];if (this.selectedPages &&@@ -246,19 +246,15 @@ export class ReorderPagesCommand extends DOMCommand {).filter((page) => page !== undefined) as PDFPage[];- const remainingPages = newPages.filter(+ const remainingPages = currentDoc.pages.filter((page) => !this.selectedPages!.includes(page.pageNumber),);remainingPages.splice(this.targetIndex, 0, ...selectedPageObjects);-- remainingPages.forEach((page, index) => {- page.pageNumber = index + 1;- });-- newPages.splice(0, newPages.length, ...remainingPages);+ reorderedPages = remainingPages;} else {// Single page reorder- const [movedPage] = newPages.splice(sourceIndex, 1);+ const working = [...currentDoc.pages];+ const [movedPage] = working.splice(sourceIndex, 1);// Adjust target index if moving forward (after removal, indices shift)const adjustedTargetIndex =@@ -266,13 +262,15 @@ export class ReorderPagesCommand extends DOMCommand {? this.targetIndex - 1: this.targetIndex;- newPages.splice(adjustedTargetIndex, 0, movedPage);-- newPages.forEach((page, index) => {- page.pageNumber = index + 1;- });+ working.splice(adjustedTargetIndex, 0, movedPage);+ reorderedPages = working;}+ const newPages = reorderedPages.map((page, index) => ({+ ...page,+ pageNumber: index + 1,+ }));+const reorderedDocument: PDFDocument = {...currentDoc,pages: newPages,