Skip to content

Commit

Permalink
perf: menu performance optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Jun 26, 2021
1 parent d028cce commit e8b9578
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions components/menu/src/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default defineComponent({
}
keyMapStore.value = newKeyMapStore;
},
{ immediate: true },
{ flush: 'post' },
);
watchEffect(() => {
if (props.activeKey !== undefined) {
Expand Down Expand Up @@ -209,12 +209,17 @@ export default defineComponent({
{ immediate: true },
);

let timeout: number;
const changeActiveKeys = (keys: Key[]) => {
if (props.activeKey === undefined) {
activeKeys.value = keys;
}
emit('update:activeKey', keys[keys.length - 1]);
window.clearTimeout(timeout);
timeout = window.setTimeout(() => {
if (props.activeKey === undefined) {
activeKeys.value = keys;
}
emit('update:activeKey', keys[keys.length - 1]);
});
};

const disabled = computed(() => !!props.disabled);
const isRtl = computed(() => direction.value === 'rtl');
const mergedMode = ref<MenuMode>('vertical');
Expand Down Expand Up @@ -389,10 +394,8 @@ export default defineComponent({
));
const overflowedIndicator = <EllipsisOutlined />;

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

0 comments on commit e8b9578

Please sign in to comment.