diff --git a/packages/xgen/layouts/wrappers/Chat/Container/Header.tsx b/packages/xgen/layouts/wrappers/Chat/Container/Header.tsx index 8983c14..05eb5ce 100644 --- a/packages/xgen/layouts/wrappers/Chat/Container/Header.tsx +++ b/packages/xgen/layouts/wrappers/Chat/Container/Header.tsx @@ -4,7 +4,7 @@ import { container } from 'tsyringe' import { GlobalModel } from '@/context/app' import Icon from '@/widgets/Icon' import clsx from 'clsx' -import './styles.css' +import './header.less' interface HeaderProps { openSidebar: (temporaryLink?: string, title?: string) => void @@ -223,29 +223,30 @@ const Header: FC = ({ const calculateVisibleItems = () => { // Get the header element's width - const header = container.closest('.header') as HTMLElement + const header = container.closest('.header_container') as HTMLElement if (!header) return // Get the header-right width - const headerRight = header.querySelector('.header-right') as HTMLElement + const headerRight = header.querySelector('.header_right') as HTMLElement if (!headerRight) return // Calculate available width const headerWidth = header.getBoundingClientRect().width const headerRightWidth = headerRight.getBoundingClientRect().width - const logo = header.querySelector('.header-logo') as HTMLElement - const createNew = header.querySelector('.current-function') as HTMLElement + const logo = header.querySelector('.header_logo') as HTMLElement + const createNew = header.querySelector('.header_current_function') as HTMLElement if (!logo || !createNew) return - const usedWidth = - headerRightWidth + - logo.getBoundingClientRect().width + - createNew.getBoundingClientRect().width + - 64 // Total padding and gaps + // Add some buffer for padding and spacing + const BUFFER_SPACE = 80 + const logoWidth = logo.getBoundingClientRect().width + const createNewWidth = createNew.getBoundingClientRect().width + + const usedWidth = headerRightWidth + logoWidth + createNewWidth + BUFFER_SPACE const availableWidth = headerWidth - usedWidth - const moreMenuWidth = 40 + const moreMenuWidth = 48 let currentWidth = 0 let count = 0 @@ -255,7 +256,10 @@ const Header: FC = ({ const remainingItems = itemWidthsRef.current.length - (i + 1) const needMoreMenu = remainingItems > 0 - if (currentWidth + itemWidth + (needMoreMenu ? moreMenuWidth : 0) <= availableWidth) { + // Add the "More" menu width if there will be hidden items + const totalWidthNeeded = currentWidth + itemWidth + (needMoreMenu ? moreMenuWidth : 0) + + if (totalWidthNeeded <= availableWidth) { currentWidth += itemWidth count = i + 1 } else { @@ -263,7 +267,15 @@ const Header: FC = ({ } } - setVisibleMenuItems(Math.max(1, count)) + // Ensure we show at least one item + const finalCount = Math.max(1, Math.min(count, itemWidthsRef.current.length)) + + // If we're showing all items except one, show the more menu anyway + if (finalCount === itemWidthsRef.current.length - 1) { + setVisibleMenuItems(finalCount - 1) + } else { + setVisibleMenuItems(finalCount) + } } // Initial measurement and calculation @@ -279,7 +291,7 @@ const Header: FC = ({ const resizeObserver = new ResizeObserver(recalculate) // Observe the header element instead - const header = container.closest('.header') + const header = container.closest('.header_container') if (header) { resizeObserver.observe(header) } @@ -322,10 +334,10 @@ const Header: FC = ({ const activeFunction = commonFunctions.find((func) => func.id === activeCommonFunctionId) return ( -
-
+
+
{/* Logo */} -
+
Logo
@@ -336,7 +348,7 @@ const Header: FC = ({ key: func.id, label: (
@@ -346,12 +358,12 @@ const Header: FC = ({ ), onClick: func.onClick })), - className: 'common-functions-dropdown' + className: 'header_common_functions_dropdown' }} trigger={['hover']} >
@@ -364,9 +376,9 @@ const Header: FC = ({ {/* Hidden container for measurements */} -
+
{menuItems.map((item) => ( -
+
{item.icon && } {item.name}
@@ -374,11 +386,11 @@ const Header: FC = ({
{/* Visible menu items */} -
+
{finalVisibleItems.map((item) => (
= ({ key: item.id, label: (
@@ -406,11 +418,11 @@ const Header: FC = ({ ), onClick: item.onClick })), - className: 'more-menu-items' + className: 'header_more_menu_items' }} trigger={['hover']} > -
+
@@ -418,17 +430,17 @@ const Header: FC = ({
-
+
) - return
{isTemporaryView ? renderTemporaryView() : renderNormalMenu()}
+ return ( +
{isTemporaryView ? renderTemporaryView() : renderNormalMenu()}
+ ) } export default Header diff --git a/packages/xgen/layouts/wrappers/Chat/Container/Menu.tsx b/packages/xgen/layouts/wrappers/Chat/Container/Menu.tsx index 510bc0d..3a13651 100644 --- a/packages/xgen/layouts/wrappers/Chat/Container/Menu.tsx +++ b/packages/xgen/layouts/wrappers/Chat/Container/Menu.tsx @@ -2,7 +2,7 @@ import { FC, useState, useEffect, useRef } from 'react' import { Input } from 'antd' import Icon from '@/widgets/Icon' import clsx from 'clsx' -import './styles.css' +import './menu.less' interface MenuItem { id: string @@ -208,9 +208,9 @@ const MenuItem: FC<{ } return ( -
+
-
+
{item.icon && } - {item.image && {item.name}} - {item.name} + {item.image && {item.name}} + {item.name}
{hasChildren && ( )}
{hasChildren && isExpanded && ( -
+
{item.children?.map((child) => ( = ({ isVisible = true, onToggle }) => { } return ( -