fix new page naming (#2292)

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
This commit is contained in:
alex 2023-12-06 08:54:24 +00:00 committed by GitHub
parent dcf2ad9820
commit 7f48194c8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -3791,7 +3791,7 @@ export class Editor extends EventEmitter<TLEventMap> {
const pages = this.getPages() const pages = this.getPages()
const name = getIncrementedName( const name = getIncrementedName(
page.name ?? 'Page', page.name ?? 'Page 1',
pages.map((p) => p.name) pages.map((p) => p.name)
) )

View file

@ -82,7 +82,7 @@ export const MoveToPageMenu = track(function MoveToPageMenu() {
const ids = editor.getSelectedShapeIds() const ids = editor.getSelectedShapeIds()
editor.batch(() => { editor.batch(() => {
editor.mark('move_shapes_to_page') 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) editor.moveShapesToPage(ids, newPageId)
}) })
}} }}