Skip to content

Commit e8b9578

Browse files
committed
perf: menu performance optimization
1 parent d028cce commit e8b9578

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

components/menu/src/Menu.tsx

+10-7
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default defineComponent({
107107
}
108108
keyMapStore.value = newKeyMapStore;
109109
},
110-
{ immediate: true },
110+
{ flush: 'post' },
111111
);
112112
watchEffect(() => {
113113
if (props.activeKey !== undefined) {
@@ -209,12 +209,17 @@ export default defineComponent({
209209
{ immediate: true },
210210
);
211211

212+
let timeout: number;
212213
const changeActiveKeys = (keys: Key[]) => {
213-
if (props.activeKey === undefined) {
214-
activeKeys.value = keys;
215-
}
216-
emit('update:activeKey', keys[keys.length - 1]);
214+
window.clearTimeout(timeout);
215+
timeout = window.setTimeout(() => {
216+
if (props.activeKey === undefined) {
217+
activeKeys.value = keys;
218+
}
219+
emit('update:activeKey', keys[keys.length - 1]);
220+
});
217221
};
222+
218223
const disabled = computed(() => !!props.disabled);
219224
const isRtl = computed(() => direction.value === 'rtl');
220225
const mergedMode = ref<MenuMode>('vertical');
@@ -389,10 +394,8 @@ export default defineComponent({
389394
));
390395
const overflowedIndicator = <EllipsisOutlined />;
391396

392-
// data-hack-store-update 初步判断是 vue bug,先用hack方式
393397
return (
394398
<Overflow
395-
data-hack-store-update={store.value}
396399
prefixCls={`${prefixCls.value}-overflow`}
397400
component="ul"
398401
itemComponent={MenuItem}

0 commit comments

Comments
 (0)