Task attempt 84f34dec-b9ba-4430-84ce-07645c18d0ee - Final changes
This commit is contained in:
@@ -214,16 +214,24 @@ export function FileSearchTextarea({
|
|||||||
finalLeft = 16
|
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 availableSpaceBelow = window.innerHeight - viewportTop - 32
|
||||||
const availableSpaceAbove = textareaRect.top + (currentLine * lineHeight) - 32
|
const availableSpaceAbove = textareaRect.top + (currentLine * lineHeight) - 32
|
||||||
|
|
||||||
if (availableSpaceBelow < minDropdownHeight && availableSpaceAbove > availableSpaceBelow) {
|
// Check if dropdown would be clipped at bottom - if so, try positioning above
|
||||||
// Position above the cursor line
|
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
|
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 {
|
} else {
|
||||||
// Position below the cursor line - prioritize using available space
|
// Position below the cursor line
|
||||||
maxHeight = Math.min(maxDropdownHeight, Math.max(availableSpaceBelow, minDropdownHeight))
|
maxHeight = Math.min(maxDropdownHeight, Math.max(availableSpaceBelow, minDropdownHeight))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user