浏览代码

fix: only compare key to determine whether to update the item

linyan 2 年之前
父节点
当前提交
c24a1517c1
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      packages/semi-ui/overflowList/index.tsx

+ 8 - 1
packages/semi-ui/overflowList/index.tsx

@@ -170,8 +170,15 @@ class OverflowList extends BaseComponent<OverflowListProps, OverflowListState> {
 
     componentDidUpdate(prevProps: OverflowListProps, prevState: OverflowListState): void {
 
+        const prevItemsKeys = prevProps.items.map((item) =>
+            item.key
+        );
+        const nowItemsKeys = this.props.items.map((item) =>
+            item.key
+        );
 
-        if (!isEqual(prevProps.items, this.props.items)) {
+        // Determine whether to update by comparing key values
+        if (!isEqual(prevItemsKeys, nowItemsKeys)) {
             this.itemRefs = {};
             this.setState({ visibleState: new Map() });
         }