@@ -53,32 +53,53 @@ export function HelpDialog({
5353 const bodyWidth = Math . max ( 1 , width - 4 ) ;
5454 const keyWidth = Math . min ( 16 , Math . max ( 12 , Math . floor ( bodyWidth * 0.28 ) ) ) ;
5555 const descriptionWidth = Math . max ( 1 , bodyWidth - keyWidth ) ;
56- const height = Math . min (
57- sections . reduce ( ( total , section ) => total + 1 + section . items . length , 0 ) + 3 ,
58- Math . max ( 8 , terminalHeight - 2 ) ,
56+ const contentRowCount = sections . reduce (
57+ ( rowCount , section ) => rowCount + 1 + section . items . length ,
58+ 0 ,
59+ ) ;
60+ // ModalFrame contributes the border rows, title row, padding, and one blank spacer row.
61+ const modalFrameChromeRowCount = 6 ;
62+ const requiredModalHeight = contentRowCount + modalFrameChromeRowCount ;
63+ const modalHeight = Math . min ( requiredModalHeight , Math . max ( 8 , terminalHeight - 2 ) ) ;
64+ const shouldScroll = modalHeight < requiredModalHeight ;
65+ const content = (
66+ < box style = { { width : "100%" , flexDirection : "column" } } >
67+ { sections . map ( ( section ) => (
68+ < box key = { section . title } style = { { width : "100%" , flexDirection : "column" } } >
69+ < box style = { { width : "100%" , height : 1 } } >
70+ < text fg = { theme . badgeNeutral } > { section . title } </ text >
71+ </ box >
72+ { section . items . map ( ( [ keys , description ] ) => (
73+ < box
74+ key = { `${ section . title } :${ keys } ` }
75+ style = { { width : "100%" , height : 1 , flexDirection : "row" } }
76+ >
77+ < text fg = { theme . accent } > { padText ( fitText ( keys , keyWidth ) , keyWidth ) } </ text >
78+ < text fg = { theme . muted } > { fitText ( description , descriptionWidth ) } </ text >
79+ </ box >
80+ ) ) }
81+ </ box >
82+ ) ) }
83+ </ box >
5984 ) ;
6085
6186 return (
6287 < ModalFrame
63- height = { height }
88+ height = { modalHeight }
6489 terminalHeight = { terminalHeight }
6590 terminalWidth = { terminalWidth }
6691 theme = { theme }
6792 title = "Keyboard help"
6893 width = { width }
6994 onClose = { onClose }
7095 >
71- { sections . map ( ( section ) => (
72- < box key = { section . title } style = { { flexDirection : "column" } } >
73- < text fg = { theme . badgeNeutral } > { section . title } </ text >
74- { section . items . map ( ( [ keys , description ] ) => (
75- < box key = { `${ section . title } :${ keys } ` } style = { { flexDirection : "row" } } >
76- < text fg = { theme . accent } > { padText ( fitText ( keys , keyWidth ) , keyWidth ) } </ text >
77- < text fg = { theme . muted } > { fitText ( description , descriptionWidth ) } </ text >
78- </ box >
79- ) ) }
80- </ box >
81- ) ) }
96+ { shouldScroll ? (
97+ < scrollbox focused = { false } height = "100%" scrollY = { true } width = "100%" >
98+ { content }
99+ </ scrollbox >
100+ ) : (
101+ content
102+ ) }
82103 </ ModalFrame >
83104 ) ;
84105}
0 commit comments