diff --git a/src/plugins/core/pivot.ts b/src/plugins/core/pivot.ts index 2f4c7c647d..893da873f9 100644 --- a/src/plugins/core/pivot.ts +++ b/src/plugins/core/pivot.ts @@ -95,7 +95,7 @@ export class PivotCorePlugin extends CorePlugin implements CoreState case "DUPLICATE_PIVOT": { const { pivotId, newPivotId } = cmd; const pivot = deepCopy(this.getPivotCore(pivotId).definition); - pivot.name = _t("%s (copy)", pivot.name); + pivot.name = cmd.duplicatedPivotName ?? pivot.name + " (copy)"; this.addPivot(newPivotId, pivot); break; } diff --git a/src/plugins/ui_feature/insert_pivot.ts b/src/plugins/ui_feature/insert_pivot.ts index 664af44e28..0a94432275 100644 --- a/src/plugins/ui_feature/insert_pivot.ts +++ b/src/plugins/ui_feature/insert_pivot.ts @@ -67,6 +67,7 @@ export class InsertPivotPlugin extends UIPlugin { this.dispatch("DUPLICATE_PIVOT", { pivotId, newPivotId, + duplicatedPivotName: _t("%s (copy)", this.getters.getPivotCoreDefinition(pivotId).name), }); const activeSheetId = this.getters.getActiveSheetId(); const position = this.getters.getSheetIds().indexOf(activeSheetId) + 1; diff --git a/src/types/commands.ts b/src/types/commands.ts index 3ea0941db2..a564fa0759 100644 --- a/src/types/commands.ts +++ b/src/types/commands.ts @@ -623,6 +623,8 @@ export interface DuplicatePivotCommand { type: "DUPLICATE_PIVOT"; pivotId: UID; newPivotId: string; + // an early version of the command did not include the duplicatedPivotName + duplicatedPivotName?: string; } // ------------------------------------------------ diff --git a/tests/test_helpers/constants.ts b/tests/test_helpers/constants.ts index 3524b4ddb6..0957c6f4cb 100644 --- a/tests/test_helpers/constants.ts +++ b/tests/test_helpers/constants.ts @@ -441,6 +441,7 @@ export const TEST_COMMANDS: CommandMapping = { type: "DUPLICATE_PIVOT", pivotId: "1", newPivotId: "2", + duplicatedPivotName: "newName", }, RENAME_PIVOT: { type: "RENAME_PIVOT",