From 7f48194c8fcaff609bbfe1f929970cd819207f04 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 6 Dec 2023 08:54:24 +0000 Subject: [PATCH] fix new page naming (#2292) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When creating a new page from the "move to page" menu it would be created as just "Page" instead of "page 1" etc. ### Change Type - [x] `patch` — Bug fix ### Test Plan 1. Start from an empty canvas 2. Add some stuff to the canvas 3. Select it, right click, and choose "move to page" -> "new page" 4. The newly created page should be called "page 2" ### Release Notes - Fix naming of pages created by the "move to page" action --- packages/editor/src/lib/editor/Editor.ts | 2 +- packages/tldraw/src/lib/ui/components/MoveToPageMenu.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/lib/editor/Editor.ts b/packages/editor/src/lib/editor/Editor.ts index b4c128523..39c045025 100644 --- a/packages/editor/src/lib/editor/Editor.ts +++ b/packages/editor/src/lib/editor/Editor.ts @@ -3791,7 +3791,7 @@ export class Editor extends EventEmitter { const pages = this.getPages() const name = getIncrementedName( - page.name ?? 'Page', + page.name ?? 'Page 1', pages.map((p) => p.name) ) diff --git a/packages/tldraw/src/lib/ui/components/MoveToPageMenu.tsx b/packages/tldraw/src/lib/ui/components/MoveToPageMenu.tsx index 4aecef6c0..7379b5d04 100644 --- a/packages/tldraw/src/lib/ui/components/MoveToPageMenu.tsx +++ b/packages/tldraw/src/lib/ui/components/MoveToPageMenu.tsx @@ -82,7 +82,7 @@ export const MoveToPageMenu = track(function MoveToPageMenu() { const ids = editor.getSelectedShapeIds() editor.batch(() => { editor.mark('move_shapes_to_page') - editor.createPage({ name: 'Page', id: newPageId }) + editor.createPage({ name: msg('page-menu.new-page-initial-name'), id: newPageId }) editor.moveShapesToPage(ids, newPageId) }) }}