Skip to content

Commit

Permalink
fix(tabs): fix tabs tabPanel label change tabbar not update (#3134)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaixingOoO authored Oct 14, 2024
1 parent 6a6eacd commit 097a9fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/tabs/TabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import React, { useEffect, useState, CSSProperties, useRef } from 'react';
import classNames from 'classnames';
import useConfig from '../hooks/useConfig';
import useMutationObserver from '../hooks/useMutationObserver';
import useResizeObserver from '../hooks/useResizeObserver';

interface TabBarProps {
tabPosition: string;
activeId: string | number;
containerRef: React.MutableRefObject<HTMLDivElement>;
navsWrapRef: React.MutableRefObject<HTMLDivElement>;
}

const TabBar: React.FC<TabBarProps> = (props) => {
const { tabPosition, activeId, containerRef } = props;
const { tabPosition, activeId, containerRef, navsWrapRef } = props;
const { classPrefix } = useConfig();
const [barStyle, setBarStyle] = useState<CSSProperties>({});
const tabsClassPrefix = `${classPrefix}-tabs`;
Expand Down Expand Up @@ -66,6 +68,8 @@ const TabBar: React.FC<TabBarProps> = (props) => {

useMutationObserver(containerRef.current, handleMutationObserver);

useResizeObserver(navsWrapRef.current, computeStyle);

return (
<div
className={classNames({
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/TabNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const TabNav: React.FC<TabNavProps> = (props) => {

// TabBar 组件逻辑层抽象,卡片类型时无需展示,故将逻辑整合到此处
const TabBarCom = isCard ? null : (
<TabBar tabPosition={placement} activeId={activeIndex} containerRef={navsWrapRef} />
<TabBar tabPosition={placement} activeId={activeIndex} containerRef={navsWrapRef} navsWrapRef={navsWrapRef} />
);

const handleTabItemRemove = (removeItem) => {
Expand Down

0 comments on commit 097a9fb

Please sign in to comment.