ENG-1742 Add max height and scroll for node type menu#1019
Conversation
Adds `max-h-[60vh] overflow-y-auto` to the node menu list so it doesn't overflow off-screen when there are many node types. Also scrolls the active item into view when navigating with arrow keys. Co-authored-by: Cursor <cursoragent@cursor.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
| const parentTop = | ||
| props.textarea.parentElement?.getBoundingClientRect().top ?? 0; | ||
| const menuMaxHeight = window.innerHeight - (parentTop + coords.top) - 24; |
There was a problem hiding this comment.
The menuMaxHeight calculation can result in negative or extremely small values when there is insufficient vertical space below the menu position. This will cause the menu to be unusable or invisible.
Unlike the second calculation at lines 377-380 which uses Math.max(..., 100) to ensure a minimum height, this calculation has no safeguard.
Fix:
const menuMaxHeight = Math.max(
window.innerHeight - (parentTop + coords.top) - 24,
100
);| const parentTop = | |
| props.textarea.parentElement?.getBoundingClientRect().top ?? 0; | |
| const menuMaxHeight = window.innerHeight - (parentTop + coords.top) - 24; | |
| const parentTop = | |
| props.textarea.parentElement?.getBoundingClientRect().top ?? 0; | |
| const menuMaxHeight = Math.max( | |
| window.innerHeight - (parentTop + coords.top) - 24, | |
| 100 | |
| ); | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
There was a problem hiding this comment.
There was a problem hiding this comment.
Yes I enabled flipping from the Popover and here's the updated behavior
https://www.loom.com/share/1dfdf25d641f410b8f0d9f971d943820
mdroidian
left a comment
There was a problem hiding this comment.
Let's try to use the built in <Popover> position prop to deal with where is should render, instead of trying to render a very very small scrollable menu.
| const parentTop = | ||
| props.textarea.parentElement?.getBoundingClientRect().top ?? 0; | ||
| const menuMaxHeight = window.innerHeight - (parentTop + coords.top) - 24; |
There was a problem hiding this comment.

https://www.loom.com/share/2c6b19da26f345a488119a7fe028e4d8
Summary
max-h-[60vh] overflow-y-autoto the node type menu so it doesn't overflow off-screen when there are many node typesFixes ENG-1742
Test plan
Made with Cursor