From 2a2ea11d9aa9f6cf744db499218dbe11ad48499b Mon Sep 17 00:00:00 2001 From: Louis Knight-Webb Date: Wed, 25 Jun 2025 00:09:13 +0100 Subject: [PATCH] Task attempt 84f34dec-b9ba-4430-84ce-07645c18d0ee - Final changes --- .../src/components/ui/file-search-textarea.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/ui/file-search-textarea.tsx b/frontend/src/components/ui/file-search-textarea.tsx index c58451c1..807926a2 100644 --- a/frontend/src/components/ui/file-search-textarea.tsx +++ b/frontend/src/components/ui/file-search-textarea.tsx @@ -214,16 +214,24 @@ export function FileSearchTextarea({ finalLeft = 16 } - // Prevent going off the bottom edge - use more generous spacing + // Smart positioning: avoid clipping by positioning above when needed const availableSpaceBelow = window.innerHeight - viewportTop - 32 const availableSpaceAbove = textareaRect.top + (currentLine * lineHeight) - 32 - if (availableSpaceBelow < minDropdownHeight && availableSpaceAbove > availableSpaceBelow) { - // Position above the cursor line + // Check if dropdown would be clipped at bottom - if so, try positioning above + const wouldBeClippedBelow = availableSpaceBelow < maxDropdownHeight + const hasEnoughSpaceAbove = availableSpaceAbove >= maxDropdownHeight + + if (wouldBeClippedBelow && hasEnoughSpaceAbove) { + // Position above the cursor line with full height finalTop = textareaRect.top + paddingTop + (currentLine * lineHeight) - maxDropdownHeight - 8 - maxHeight = Math.min(maxDropdownHeight, Math.max(availableSpaceAbove, minDropdownHeight)) + maxHeight = maxDropdownHeight + } else if (wouldBeClippedBelow && availableSpaceAbove > availableSpaceBelow) { + // Position above but with reduced height if not enough space + finalTop = textareaRect.top + paddingTop + (currentLine * lineHeight) - availableSpaceAbove - 8 + maxHeight = Math.max(availableSpaceAbove, minDropdownHeight) } else { - // Position below the cursor line - prioritize using available space + // Position below the cursor line maxHeight = Math.min(maxDropdownHeight, Math.max(availableSpaceBelow, minDropdownHeight)) }