From 56e59aa6f5a0df191e10d0f133fd558eefdb0548 Mon Sep 17 00:00:00 2001 From: vincentLiuxiang Date: Sun, 13 Jun 2021 14:46:09 +0800 Subject: [PATCH] feat: support overwrite the more tabs dropdown props (https://github.com/react-component/tabs/issues/396) --- src/TabNavList/OperationNode.tsx | 12 ++++++++---- src/TabNavList/index.tsx | 12 ++++++++---- src/Tabs.tsx | 12 ++++++++---- tests/operation-overflow.test.tsx | 30 +++++++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/TabNavList/OperationNode.tsx b/src/TabNavList/OperationNode.tsx index ec106aaa..a90f0e12 100644 --- a/src/TabNavList/OperationNode.tsx +++ b/src/TabNavList/OperationNode.tsx @@ -6,6 +6,7 @@ import Menu, { MenuItem } from 'rc-menu'; import Dropdown from 'rc-dropdown'; import type { Tab, TabsLocale, EditableConfig } from '../interface'; import AddButton from './AddButton'; +import type { DropdownProps } from 'rc-dropdown/lib/Dropdown'; export interface OperationNodeProps { prefixCls: string; @@ -19,6 +20,7 @@ export interface OperationNodeProps { mobile: boolean; moreIcon?: React.ReactNode; moreTransitionName?: string; + moreTabsDropdownProps?: Partial; editable?: EditableConfig; locale?: TabsLocale; onTabClick: (key: React.Key, e: React.MouseEvent | React.KeyboardEvent) => void; @@ -39,6 +41,7 @@ function OperationNode( tabBarGutter, rtl, onTabClick, + moreTabsDropdownProps, }: OperationNodeProps, ref: React.Ref, ) { @@ -65,7 +68,7 @@ function OperationNode( selectedKeys={[selectedKey]} aria-label={dropdownAriaLabel !== undefined ? dropdownAriaLabel : 'expanded dropdown'} > - {tabs.map(tab => ( + {tabs.map((tab) => ( !tab.disabled); - let selectedIndex = enabledTabs.findIndex(tab => tab.key === selectedKey) || 0; + const enabledTabs = tabs.filter((tab) => !tab.disabled); + let selectedIndex = enabledTabs.findIndex((tab) => tab.key === selectedKey) || 0; const len = enabledTabs.length; for (let i = 0; i < len; i += 1) { @@ -149,7 +152,7 @@ function OperationNode( } const overlayClassName = classNames({ - [`${dropdownPrefix}-rtl`]: rtl + [`${dropdownPrefix}-rtl`]: rtl, }); const moreNode: React.ReactElement = mobile ? null : ( @@ -163,6 +166,7 @@ function OperationNode( overlayClassName={overlayClassName} mouseEnterDelay={0.1} mouseLeaveDelay={0.1} + {...moreTabsDropdownProps} >