Skip to content

Commit

Permalink
* kanban: fix KanbanRegion.update not work as expected.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Nov 23, 2023
1 parent 5e90376 commit 5e286b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/kanban/src/component/kanban-region.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ export class KanbanRegion extends HElement<KanbanRegionProps, KanbanRegionState>
};

_buildItems(props: RenderableProps<KanbanRegionProps>): 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;
Expand Down
5 changes: 4 additions & 1 deletion lib/kanban/src/component/kanban.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,10 @@ export class Kanban<P extends KanbanProps = KanbanProps, S extends KanbanState =
if (link[itemKey] === undefined) {
link[itemKey] = `${link.from}:${link.to}`;
}
list.push(link);
const finalLink = props.getLink?.call(this, link) ?? link;
if (finalLink !== false && !finalLink.deleted) {
list.push(finalLink);
}
}
return list;
}, []);
Expand Down
2 changes: 1 addition & 1 deletion lib/kanban/src/helpers/kanban-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function mergeList<T extends {}>(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<string, number>());
Expand Down

0 comments on commit 5e286b7

Please sign in to comment.