Skip to content

Commit efc392e

Browse files
committed
Fix: Select Modal Layout & Collapse Button Detect Region Check
1 parent 8cdd736 commit efc392e

File tree

4 files changed

+36
-15
lines changed

4 files changed

+36
-15
lines changed

src/components/chat/ChatHistoryList.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const ChatHistoryList: React.FC<ChatHistoryListProps> = ({
7474

7575
const inputRef = useRef<HTMLInputElement>(null);
7676
const sidebarRef = useRef<HTMLDivElement>(null);
77+
const toggleButtonRef = useRef<HTMLButtonElement>(null);
7778

7879
// Focus input when editing
7980
useEffect(() => {
@@ -109,14 +110,19 @@ export const ChatHistoryList: React.FC<ChatHistoryListProps> = ({
109110
if (!sidebarRef.current || isButtonHovered) return;
110111

111112
// Get sidebar element dimensions and position
112-
const rect = sidebarRef.current.getBoundingClientRect();
113+
const rect = toggleButtonRef.current?.getBoundingClientRect();
114+
if (!rect) return;
113115
const sidebarRight = rect.right;
116+
const sidebarYCenter = rect.top + rect.height / 2;
114117

115118
// Define the sensitivity area (how close the mouse needs to be to show the button)
116-
const sensitivityArea = 40; // pixels
119+
const sensitivityArea = 70; // pixels
117120

118121
// Check if mouse is within the sensitivity area
119-
const isNearToggle = Math.abs(e.clientX - sidebarRight) < sensitivityArea;
122+
const isNearToggle = Math.abs(e.clientX - sidebarRight) < sensitivityArea
123+
&& Math.abs(e.clientY - sidebarYCenter) < sensitivityArea;
124+
125+
console.log('isNearToggle', isNearToggle);
120126

121127
// Only update if the value is different to avoid unnecessary re-renders
122128
if (isNearToggle !== isButtonVisible) {
@@ -219,7 +225,8 @@ export const ChatHistoryList: React.FC<ChatHistoryListProps> = ({
219225
if (!sidebarRef.current) return;
220226

221227
const rect = sidebarRef.current.getBoundingClientRect();
222-
const isNearToggle = Math.abs(mousePosition.x - rect.right) < 40;
228+
const isNearToggle = Math.abs(mousePosition.x - rect.right) < 40
229+
&& Math.abs(mousePosition.y - rect.top) < 40;
223230

224231
if (!isNearToggle && !isSidebarHovered) {
225232
setIsButtonVisible(false);
@@ -238,7 +245,9 @@ export const ChatHistoryList: React.FC<ChatHistoryListProps> = ({
238245
if (!isButtonHovered) {
239246
const rect = sidebarRef.current?.getBoundingClientRect();
240247
if (rect) {
241-
const isNearToggle = Math.abs(mousePosition.x - rect.right) < 40;
248+
const isNearToggle = Math.abs(mousePosition.x - rect.right) < 40
249+
&& Math.abs(mousePosition.y - rect.top) < 40;
250+
242251
if (!isNearToggle) {
243252
setIsButtonVisible(false);
244253
}
@@ -408,12 +417,13 @@ export const ChatHistoryList: React.FC<ChatHistoryListProps> = ({
408417

409418
{/* Collapse toggle button */}
410419
<button
420+
ref={toggleButtonRef}
411421
onClick={toggleSidebar}
412422
onMouseEnter={handleButtonMouseEnter}
413423
onMouseLeave={handleButtonMouseLeave}
414424
onFocus={() => setIsButtonVisible(true)}
415425
onBlur={() => !isSidebarHovered && setIsButtonVisible(false)}
416-
className={`absolute z-10 flex items-center justify-center w-6 h-20 transform -translate-y-1/2 bg-gray-200 -right-6 top-1/2 hover:bg-gray-300 rounded-r-md transition-opacity duration-300 ${isButtonVisible || isButtonHovered ? 'opacity-100' : 'opacity-0'}`}
426+
className={`absolute chat-history-list-collapse-button z-10 flex items-center justify-center w-6 h-20 transform -translate-y-1/2 -right-6 top-1/2 rounded-r-md transition-opacity duration-300 ${isButtonVisible || isButtonHovered ? 'opacity-100' : 'opacity-0'}`}
417427
aria-label={isCollapsed ? 'Expand sidebar' : 'Collapse sidebar'}
418428
title={isCollapsed ? 'Expand sidebar' : 'Collapse sidebar'}
419429
>

src/components/models/SelectModelDialog.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const SelectModelDialog: React.FC<SelectModelDialogProps> = ({
115115
onClick={onClose}
116116
>
117117
<div
118-
className="flex flex-col w-3/4 p-4 h-4/5 select-model-dialog move-in"
118+
className="flex flex-col w-1/2 p-4 min-h-[500px] min-w-[560px] overflow-hidden h-3/5 select-model-dialog move-in"
119119
onClick={(e) => e.stopPropagation()}
120120
>
121121
<div className="flex items-center justify-between pb-2 border-b frame-separator-border-color">
@@ -129,8 +129,8 @@ export const SelectModelDialog: React.FC<SelectModelDialogProps> = ({
129129
</button>
130130
</div>
131131

132-
<div className="flex items-center justify-between p-4 border-b frame-separator-border-color">
133-
<div className="relative flex-1 max-w-md">
132+
<div className="flex items-center justify-between w-full px-8 py-4 border-b frame-separator-border-color">
133+
<div className="relative flex-1 w-full">
134134
<input
135135
type="text"
136136
placeholder="Search models..."
@@ -156,18 +156,18 @@ export const SelectModelDialog: React.FC<SelectModelDialogProps> = ({
156156
</button> */}
157157
</div>
158158

159-
<div className="flex-1 p-4 overflow-y-auto">
159+
<div className="relative flex-1 p-4 max-h-[70%] overflow-y-auto">
160160
{isLoading && models.length === 0 ? (
161-
<div className="flex flex-col items-center justify-center h-64">
161+
<div className="flex flex-col items-center justify-center h-full">
162162
<Loader2 className="mb-4 text-4xl text-blue-500 animate-spin" size={40} />
163163
<p className="text-gray-400">Loading available models...</p>
164164
</div>
165165
) : filteredModels.length === 0 ? (
166-
<div className="py-8 text-center text-gray-400">
166+
<div className="flex items-center justify-center h-full text-gray-400">
167167
{searchQuery ? 'No models match your search' : 'No models available'}
168168
</div>
169169
) : (
170-
<div className="space-y-6">
170+
<div className="flex flex-col h-full">
171171
{Object.entries(groupedModels).map(([providerId, providerModels]) => (
172172
<div key={providerId} className="mb-6">
173173

src/components/settings/ApiManagement.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ export const ApiManagement: React.FC<ApiManagementProps> = ({
374374
</div>
375375

376376
<div className="sticky bottom-0 w-full">
377-
<button onClick={() => onAddCustomProvider()} className="flex items-center w-full px-4 py-2 settings-add-custom-provider-btn">
377+
<button onClick={() => onAddCustomProvider()} className="flex items-center justify-center w-full px-4 py-2 settings-add-custom-provider-btn">
378378
<Plus size={16} className="mr-2 text-base" />
379379
<span>Add Custom Provider</span>
380380
</button>

src/styles/tensorblock-light.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
--green-200: #C7F4D7;
2424
--green-500: #46C173;
2525
--green-600: #3AA461;
26-
2726
}
2827

2928
@layer base {
@@ -543,5 +542,17 @@
543542
background-color: var(--primary-200);
544543
color: var(--primary-700);
545544
}
545+
546+
.chat-history-list-collapse-button {
547+
background-color: var(--primary-100);
548+
}
549+
550+
.chat-history-list-collapse-button:hover {
551+
background-color: var(--primary-200);
552+
}
553+
554+
.chat-history-list-collapse-button:active {
555+
background-color: var(--primary-300);
556+
}
546557

547558
}

0 commit comments

Comments
 (0)