因此,我使用 Material UI 的菜单组件制作了一个下拉组件,但默认情况下菜单组件在右侧打开。我需要它实际上向左打开。
我尝试过设计它的样式,最终可以让它随着边距移动,但我正在寻找更可靠的东西。老实说,我很惊讶没有任何支撑。
我希望它从那里开始,只需打开另一个方向。任何帮助表示赞赏!
我的代码如下: 组件
function DropDown({
dropDownMeta,
style = { container: {}, icon: {} },
icon = <MenuIcon style={{ ...style.icon }} />
}: DropDownProps): ReactElement {
const [menuAnchor, setMenuAnchor] = useState<null | HTMLElement>(null)
const handleMenuClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setMenuAnchor(event.currentTarget)
}
const handleMenuClose = () => {
setMenuAnchor(null)
}
const classes = useStyles()
return (
<Box style={{ ...style.container }}>
<StyledIconButton
style={{ ...style.buttonContainer }}
onClick={handleMenuClick}
>
{icon}
</StyledIconButton>
<Menu
anchorEl={menuAnchor}
keepMounted
open={Boolean(menuAnchor)}
onClose={handleMenuClose} …Run Code Online (Sandbox Code Playgroud)