@@ -39,6 +39,7 @@ export function MenuDropdown({
3939 activeMenuItemIndex,
4040 activeMenuSpec,
4141 activeMenuWidth,
42+ terminalWidth,
4243 theme,
4344 onHoverItem,
4445 onSelectItem,
@@ -48,17 +49,21 @@ export function MenuDropdown({
4849 activeMenuItemIndex : number ;
4950 activeMenuSpec : MenuSpec ;
5051 activeMenuWidth : number ;
52+ terminalWidth : number ;
5153 theme : AppTheme ;
5254 onHoverItem : ( index : number ) => void ;
5355 onSelectItem : ( entry : Extract < MenuEntry , { kind : "item" } > ) => void ;
5456} ) {
57+ const clampedWidth = Math . min ( activeMenuWidth , Math . max ( 22 , terminalWidth - 2 ) ) ;
58+ const clampedLeft = Math . max ( 1 , Math . min ( activeMenuSpec . left , terminalWidth - clampedWidth - 1 ) ) ;
59+
5560 return (
5661 < box
5762 style = { {
5863 position : "absolute" ,
5964 top : 1 ,
60- left : activeMenuSpec . left ,
61- width : activeMenuWidth ,
65+ left : clampedLeft ,
66+ width : clampedWidth ,
6267 height : activeMenuEntries . length + 2 ,
6368 zIndex : 40 ,
6469 border : true ,
@@ -73,9 +78,7 @@ export function MenuDropdown({
7378 key = { `${ activeMenuId } :separator:${ index } ` }
7479 style = { { height : 1 , paddingLeft : 1 , paddingRight : 1 } }
7580 >
76- < text fg = { theme . border } >
77- { padText ( "-" . repeat ( activeMenuWidth - 4 ) , activeMenuWidth - 2 ) }
78- </ text >
81+ < text fg = { theme . border } > { padText ( "-" . repeat ( clampedWidth - 4 ) , clampedWidth - 2 ) } </ text >
7982 </ box >
8083 ) : (
8184 < box
@@ -90,7 +93,7 @@ export function MenuDropdown({
9093 onMouseOver = { ( ) => onHoverItem ( index ) }
9194 onMouseUp = { ( ) => onSelectItem ( entry ) }
9295 >
93- { renderMenuLine ( entry , activeMenuWidth - 2 , theme , activeMenuItemIndex === index ) }
96+ { renderMenuLine ( entry , clampedWidth - 2 , theme , activeMenuItemIndex === index ) }
9497 </ box >
9598 ) ,
9699 ) }
0 commit comments