From f3a12411367b51b5b2ae6c6077da0b4aac152294 Mon Sep 17 00:00:00 2001 From: xiaozisong Date: Thu, 11 Jan 2024 01:35:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E5=AE=B9=E5=99=A8=E5=8F=AF=E8=A7=86?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E4=BD=8E=E4=BA=8E=E6=95=B4=E4=BD=93=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=E8=BF=9B=E8=A1=8C=E5=88=87=E6=8D=A2=E6=97=B6,?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E8=8F=9C=E5=8D=95=E6=97=A0=E6=B3=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=9A=90=E8=97=8F=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/TabNavList/index.tsx | 2 ++ src/hooks/useVisibleRange.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/TabNavList/index.tsx b/src/TabNavList/index.tsx index ff0add85..c335df07 100644 --- a/src/TabNavList/index.tsx +++ b/src/TabNavList/index.tsx @@ -218,6 +218,8 @@ function TabNavList(props: TabNavListProps, ref: React.Ref) { addSizeValue, // Operation operationSizeValue, + containerExcludeExtraSizeValue, + activeKey, { ...props, tabs }, ); diff --git a/src/hooks/useVisibleRange.ts b/src/hooks/useVisibleRange.ts index 1fd56a0d..a246fa7e 100644 --- a/src/hooks/useVisibleRange.ts +++ b/src/hooks/useVisibleRange.ts @@ -13,6 +13,8 @@ export default function useVisibleRange( tabContentSizeValue: number, addNodeSizeValue: number, operationNodeSizeValue: number, + containerExcludeExtraSizeValue: number, + activeKey: string, { tabs, tabPosition, rtl }: { tabs: Tab[] } & TabNavListProps, ): [visibleStart: number, visibleEnd: number] { let charUnit: 'width' | 'height'; @@ -34,6 +36,16 @@ export default function useVisibleRange( return [0, 0]; } + if (containerExcludeExtraSizeValue < tabContentSizeValue) { + let filterIndex + tabs.forEach((item, index) => { + if ((item.tabKey || item.key) === activeKey) { + filterIndex = index + } + }) + return [filterIndex, filterIndex] + } + const len = tabs.length; let endIndex = len; for (let i = 0; i < len; i += 1) { From 52e23e7a13187b9c7bb4d1ac75d6f223b0e05021 Mon Sep 17 00:00:00 2001 From: shawn <67359137+xiaozisong@users.noreply.github.com> Date: Sun, 28 Jan 2024 23:43:47 +0800 Subject: [PATCH 2/3] Update src/hooks/useVisibleRange.ts Co-authored-by: afc163 --- src/hooks/useVisibleRange.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/hooks/useVisibleRange.ts b/src/hooks/useVisibleRange.ts index a246fa7e..a696e1d7 100644 --- a/src/hooks/useVisibleRange.ts +++ b/src/hooks/useVisibleRange.ts @@ -37,12 +37,7 @@ export default function useVisibleRange( } if (containerExcludeExtraSizeValue < tabContentSizeValue) { - let filterIndex - tabs.forEach((item, index) => { - if ((item.tabKey || item.key) === activeKey) { - filterIndex = index - } - }) + const filterIndex = tabs.findIndex(item => (item.tabKey || item.key) === activeKey); return [filterIndex, filterIndex] } From 2f526f719b259ed7da32e4212a3f7d4c6adbfff7 Mon Sep 17 00:00:00 2001 From: xiaozisong <1170957523@qq.com> Date: Tue, 30 Jan 2024 00:32:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/overflow.test.tsx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/overflow.test.tsx b/tests/overflow.test.tsx index 718e4ae6..18b2ec93 100644 --- a/tests/overflow.test.tsx +++ b/tests/overflow.test.tsx @@ -451,6 +451,41 @@ describe('Tabs.Overflow', () => { expect(document.querySelector('.rc-tabs-dropdown-menu').textContent).not.toContain('miu'); }); + it('should be displayed in the minimum width dropdown menu', () => { + const items = [ + { + key: '1', + label: 'Tab 1', + children: 'Tab 1', + }, + { + key: '2', + label: 'Tab 2', + children: 'Tab 2', + }, + { + key: '3', + label: 'Tab 3', + children: 'Tab 3', + }, + ] + jest.useFakeTimers(); + + const { container } = render(getTabs({ items, activeKey: items[0].key, style: { width: '70px' } })); + + act(() => { + jest.runAllTimers(); + }); + fireEvent.click(container.querySelectorAll('.rc-tabs-tab')[1]) + + fireEvent.mouseEnter(container.querySelector('.rc-tabs-nav-more')); + act(() => { + jest.runAllTimers(); + }); + + expect(document.querySelector('.rc-tabs-dropdown-menu').textContent).not.toContain(items[1].key); + }); + it('should support getPopupContainer', () => { const div = document.createElement('div'); document.body.appendChild(div);