From 89b4ab4d3eff2f935bb2b7d6536c7fdb777509eb Mon Sep 17 00:00:00 2001 From: one Date: Wed, 3 Sep 2025 13:12:51 +0800 Subject: [PATCH] fix: tabs overflow, add scrollbar --- .../src/components/Tab/TabContainer.tsx | 86 +++++++++++-------- 1 file changed, 52 insertions(+), 34 deletions(-) diff --git a/src/renderer/src/components/Tab/TabContainer.tsx b/src/renderer/src/components/Tab/TabContainer.tsx index ae751899d1..25f0d2b36f 100644 --- a/src/renderer/src/components/Tab/TabContainer.tsx +++ b/src/renderer/src/components/Tab/TabContainer.tsx @@ -1,5 +1,7 @@ import { PlusOutlined } from '@ant-design/icons' +import { TopNavbarOpenedMinappTabs } from '@renderer/components/app/PinnedMinapps' import { Sortable, useDndReorder } from '@renderer/components/dnd' +import Scrollbar from '@renderer/components/Scrollbar' import { isLinux, isMac, isWin } from '@renderer/config/constant' import { useTheme } from '@renderer/context/ThemeProvider' import { useFullscreen } from '@renderer/hooks/useFullscreen' @@ -34,8 +36,6 @@ import { useTranslation } from 'react-i18next' import { useLocation, useNavigate } from 'react-router-dom' import styled from 'styled-components' -import { TopNavbarOpenedMinappTabs } from '../app/PinnedMinapps' - interface TabsContainerProps { children: React.ReactNode } @@ -155,36 +155,40 @@ const TabsContainer: React.FC = ({ children }) => { return ( - ( - handleTabClick(tab)}> - - {tab.id && {getTabIcon(tab.id)}} - {getTitleLabel(tab.id)} - - {tab.id !== 'home' && ( - { - e.stopPropagation() - closeTab(tab.id) - }}> - - + + + ( + handleTabClick(tab)}> + + {tab.id && {getTabIcon(tab.id)}} + {getTitleLabel(tab.id)} + + {tab.id !== 'home' && ( + { + e.stopPropagation() + closeTab(tab.id) + }}> + + + )} + )} - - )} - /> - - - + /> + + + + + ` @@ -236,6 +241,20 @@ const TabsBar = styled.div<{ $isFullscreen: boolean }>` } ` +const TabsArea = styled.div` + display: flex; + align-items: center; + flex: 1 1 auto; + min-width: 0; + overflow: hidden; +` + +const TabsScroll = styled(Scrollbar)` + &::-webkit-scrollbar { + display: none; + } +` + const Tab = styled.div<{ active?: boolean }>` display: flex; align-items: center; @@ -248,13 +267,10 @@ const Tab = styled.div<{ active?: boolean }>` height: 30px; min-width: 90px; transition: background 0.2s; - white-space: nowrap; - overflow: hidden; .close-button { opacity: 0; transition: opacity 0.2s; - flex-shrink: 0; } &:hover { @@ -322,6 +338,7 @@ const RightButtonsContainer = styled.div` display: flex; align-items: center; gap: 6px; + margin-left: auto; flex-shrink: 0; ` @@ -363,6 +380,7 @@ const TabContent = styled.div` margin: 6px; margin-top: 0; border-radius: 8px; + overflow: hidden; ` export default TabsContainer