diff --git a/packages/builder/src/helpers/duplicate.ts b/packages/builder/src/helpers/duplicate.ts index 4816bcfd7b..35beb4df38 100644 --- a/packages/builder/src/helpers/duplicate.ts +++ b/packages/builder/src/helpers/duplicate.ts @@ -70,10 +70,16 @@ export const duplicateName = (name: string, allNames: string[]) => { * @param getName optional function to extract the name for an item, if not a * flat array of strings */ -export const getSequentialName = ( - items: string[], +export const getSequentialName = ( + items: T[], prefix: string, - { getName = (x: string) => x, numberFirstItem = false } = {} + { + getName, + numberFirstItem, + }: { + getName: (item: T) => string + numberFirstItem?: boolean + } ) => { if (!prefix?.length || !getName) { return null diff --git a/packages/builder/src/stores/builder/rowActions.ts b/packages/builder/src/stores/builder/rowActions.ts index 9576eccd1b..2b3077926e 100644 --- a/packages/builder/src/stores/builder/rowActions.ts +++ b/packages/builder/src/stores/builder/rowActions.ts @@ -62,7 +62,7 @@ export class RowActionStore extends BudiStore { const existingRowActions = get(this)[tableId] || [] name = getSequentialName(existingRowActions, "New row action ", { getName: x => x.name, - }) + })! } if (!name) {