File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -67,8 +67,14 @@ export const SuggestionMenu = ({
6767 ) ,
6868 )
6969
70- // Account for button padding (paddingLeft + paddingRight = 2)
71- const availableWidth = menuWidth - 2
70+ // Find the longest description to determine if we can use same-line layout
71+ const maxDescriptionLength = Math . max (
72+ ...visibleItems . map ( ( item ) => item . description . length ) ,
73+ )
74+
75+ // Check if all items can fit on same line with aligned descriptions
76+ const minWidthForSameLine = maxLabelLength + 2 + maxDescriptionLength
77+ const useSameLine = menuWidth >= minWidthForSameLine
7278
7379 const renderSuggestionItem = ( item : SuggestionItem , idx : number ) => {
7480 const absoluteIndex = start + idx
@@ -86,10 +92,7 @@ export const SuggestionMenu = ({
8692 setHasHoveredSinceOpen ( true )
8793 }
8894
89- // Check per-item if description fits on the same line (using maxLabelLength for alignment padding)
90- const itemFitsOnSameLine = availableWidth >= maxLabelLength + 2 + item . description . length
91-
92- if ( itemFitsOnSameLine ) {
95+ if ( useSameLine ) {
9396 // Calculate padding to align descriptions
9497 const paddingLength = maxLabelLength - labelLength
9598 const padding = ' ' . repeat ( paddingLength )
You can’t perform that action at this time.
0 commit comments