-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Submenu with many menu items are not correct calculated top position #3871
Comments
You can work around this by using custom styles and Maybe there is a more automated solution to this problem as you suggested... the MenuItem component would have to measure scrollheight when a submenu opens up and the available scroll container space... open to proposals / PRs |
How about using 'styled components'? https://codesandbox.io/s/festive-cdn-or8xq Can I get this issue to make PR? |
@IMHOJEONG if you are suggesting to add a dependency on styled-components to solve this issue, then no, we are not going to do that in Blueprint. If you attempt to solve this issue then it should be done without any external dependencies. |
Oh, I see. I will try to find a way without dependencies. |
You can partially solve the problem by scrolling. But, due to this solution, 2 problems appear:
https://codesandbox.io/s/nostalgic-microservice-zhtzg I suppose that the best solution would be to create your own Scrollbars component inside the blueprint, and to implement the scrollbar recount when opening the following menu levels |
I would like to contribute to solving this problem, but I can not run blueprint locally on my machine. |
How about this comment? https://github.com/dotnet/corefx/issues/26966#issuecomment-367066252 |
In case it helps others landing here, my hacky workaround is to create submenus manually (as opposed to just nesting export interface PopoverMenuEntry {
readonly label: string;
readonly children?: PopoverMenuEntry[];
}
interface PopoverMenuProps {
readonly entries: readonly PopoverMenuEntry[];
}
export const PopoverMenu = React.memo(function PopoverMenu(props: PopoverMenuProps) {
return (
<Menu style={{ maxHeight: 'calc(100vh - 64px)', overflow: 'auto' }}>
{props.entries.map(renderPopoverMenuEntry)}
</Menu>
)
});
function renderPopoverMenuEntry(item: PopoverMenuEntry) {
return <MenuItem
text={item.label}
key={item.label}
children={item.children ?
<PopoverMenu entries={item.children} /> :
undefined} />;
} In my app, that safe margin of 64px is enough. Without that, blueprint keeps a padding on the bottom of the page which makes the first element in the menu go offscreen. |
Environment
https://codesandbox.io/s/gifted-snow-00f0h
Steps to reproduce
Actual behavior
Big submenu is outside the window.
Expected behavior
The submenu is positioned at the top of the container and have scrolling.
Possible solution
You can position the submenu on the top edge using the position: “auto-end” property, but in this case the submenu will also be outside the window, but at the bottom of it. I think it would be right to calculate the actual size of the container and not allow the submenu to be large, but to have scrolling instead.
The text was updated successfully, but these errors were encountered: