From 5e286b702500c5cf5b832799fa30bff806f10337 Mon Sep 17 00:00:00 2001 From: sunhao Date: Thu, 23 Nov 2023 17:51:14 +0800 Subject: [PATCH] * kanban: fix KanbanRegion.update not work as expected. --- lib/kanban/src/component/kanban-region.tsx | 4 ++-- lib/kanban/src/component/kanban.tsx | 5 ++++- lib/kanban/src/helpers/kanban-helpers.ts | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/kanban/src/component/kanban-region.tsx b/lib/kanban/src/component/kanban-region.tsx index ad315ac990..17ad4067a6 100644 --- a/lib/kanban/src/component/kanban-region.tsx +++ b/lib/kanban/src/component/kanban-region.tsx @@ -81,10 +81,10 @@ export class KanbanRegion extends HElement }; _buildItems(props: RenderableProps): ComponentChildren[] { - const {items = [], kanbanProps: kanbanPropsSetting} = props; + const {items = [], kanbanProps: kanbanPropsSetting, kanbanItemKey = 'id'} = props; let {items: stateItems} = this.state; if (stateItems) { - stateItems = mergeList(items, stateItems).filter(x => !(x as {deleted?: boolean}).deleted); + stateItems = mergeList(items, stateItems, kanbanItemKey).filter(x => !(x as {deleted?: boolean}).deleted); stateItems.sort(sortByOrder as ((a: KanbanProps, b: KanbanProps) => number)); } else { stateItems = items; diff --git a/lib/kanban/src/component/kanban.tsx b/lib/kanban/src/component/kanban.tsx index dde9325d61..ff252ce257 100644 --- a/lib/kanban/src/component/kanban.tsx +++ b/lib/kanban/src/component/kanban.tsx @@ -554,7 +554,10 @@ export class Kanban

(items: T[] | undefined, newItems: T[] | if (newItems) { let order = 0; const indexMap = finalItems.reduce((map, item, index) => { - map.set(String(item[itemKey as keyof T]), index); + map.set(String(item[itemKey as keyof T] ?? index), index); order = Math.max((item as {order?: number}).order ?? index, order); return map; }, new Map());