Skip to content

Commit

Permalink
Merge pull request #17 from mark980828/master
Browse files Browse the repository at this point in the history
optimize: Reduce performance issues caused by tab switching.
  • Loading branch information
rashagu authored Oct 11, 2024
2 parents f2c2384 + 124381c commit 9af7022
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/semi-ui-vue/src/components/tabs/TabPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ const TabPane = defineComponent({
return lazyRender ? _active : true;
};

const ChildCache = defineComponent(() => () => slots.default?.());

return () => {
const children = slots.default?.();
const { tabPaneMotion: motion, tabPosition, prevActiveKey } = context.value;
const { className, style, itemKey, tabIndex, ...restProps } = props;
const active = context.value.activeKey === itemKey;
Expand Down Expand Up @@ -103,6 +104,7 @@ const TabPane = defineComponent({
(tabPane) => tabPane.itemKey === prevActiveKey
);
const hasMotion = motion && active && !isActivatedBecauseOtherTabPaneRemoved && !context.value.forceDisableMotion;

return (
<div
role="tabpanel"
Expand All @@ -127,7 +129,7 @@ const TabPane = defineComponent({
x-semi-prop="children"
{...animationEventsNeedBind}
>
{shouldRender ? children : null}
{shouldRender ? <ChildCache/> : null}
</div>
);
}}
Expand Down

0 comments on commit 9af7022

Please sign in to comment.