From cde36a3d9918c7c86a4888d536b9de33adfd1124 Mon Sep 17 00:00:00 2001 From: zombiej Date: Wed, 25 Nov 2020 21:37:36 +0800 Subject: [PATCH 1/2] feat: Support menuTab --- examples/mix.tsx | 8 +++++++- src/TabNavList/OperationNode.tsx | 6 +++--- src/TabPanelList/TabPane.tsx | 1 + tests/common/util.tsx | 3 ++- tests/overflow.test.tsx | 29 +++++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/examples/mix.tsx b/examples/mix.tsx index ead650f5..368c03f1 100644 --- a/examples/mix.tsx +++ b/examples/mix.tsx @@ -7,7 +7,13 @@ function getTabPanes(count = 50) { const tabs: React.ReactElement[] = []; for (let i = 0; i < count; i += 1) { tabs.push( - + Content of {i} , ); diff --git a/src/TabNavList/OperationNode.tsx b/src/TabNavList/OperationNode.tsx index 857ad944..add9aa68 100644 --- a/src/TabNavList/OperationNode.tsx +++ b/src/TabNavList/OperationNode.tsx @@ -73,7 +73,7 @@ function OperationNode( aria-controls={id && `${id}-panel-${tab.key}`} disabled={tab.disabled} > - {tab.tab} + {tab.menuTab ?? tab.tab} ))} @@ -149,8 +149,8 @@ function OperationNode( } const overlayClassName = classNames({ - [`${dropdownPrefix}-rtl`]: rtl - }) + [`${dropdownPrefix}-rtl`]: rtl, + }); const moreNode: React.ReactElement = mobile ? null : ( @@ -80,6 +80,7 @@ export function getTabs(props: TabsProps = null) { Miu + {moreTabs} ); } diff --git a/tests/overflow.test.tsx b/tests/overflow.test.tsx index eeb5a649..9cf5e68f 100644 --- a/tests/overflow.test.tsx +++ b/tests/overflow.test.tsx @@ -88,6 +88,35 @@ describe('Tabs.Overflow', () => { jest.useRealTimers(); }); + it('menuTab', () => { + jest.useFakeTimers(); + const wrapper = mount( + getTabs( + null, + + Test + , + ), + ); + + triggerResize(wrapper); + act(() => { + jest.runAllTimers(); + wrapper.update(); + }); + + // Click to open + wrapper.find('.rc-tabs-nav-more').simulate('mouseenter'); + jest.runAllTimers(); + wrapper.update(); + expect( + wrapper + .find('.rc-tabs-dropdown li') + .last() + .text(), + ).toEqual('Tab In Menu'); + }); + [KeyCode.SPACE, KeyCode.ENTER].forEach(code => { it(`keyboard with select keycode: ${code}`, () => { jest.useFakeTimers(); From 6cec9f85c3b7745e18796456fd637ace801cb71a Mon Sep 17 00:00:00 2001 From: zombiej Date: Wed, 25 Nov 2020 21:42:38 +0800 Subject: [PATCH 2/2] docs: Update doc --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f390cddd..efdbdc26 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ React.render( | key | string | - | corresponding to activeKey, should be unique | | forceRender | boolean | false | forced render of content in tabs, not lazy render after clicking on tabs | | tab | ReactNode | - | current tab's title corresponding to current tabPane | +| menuTab | ReactNode | - | Tab title in dropdown menu | | closeIcon | ReactNode | - | Config close icon | ## Development