Skip to content

Commit aafc16e

Browse files
authored
feat: fix dynamic width of navbar UI (casdoor#3664)
1 parent 7be026d commit aafc16e

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

web/src/ManagementPage.js

+30-26
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,6 @@ function ManagementPage(props) {
443443
return Setting.isMobile() || window.location.pathname.startsWith("/trees");
444444
}
445445

446-
const menuStyleRight = Setting.isAdminUser(props.account) && !Setting.isMobile() ? "calc(180px + 280px)" : "320px";
447-
448446
const onClose = () => {
449447
setMenuVisible(false);
450448
};
@@ -456,34 +454,40 @@ function ManagementPage(props) {
456454
return (
457455
<React.Fragment>
458456
<EnableMfaNotification account={props.account} />
459-
<Header style={{padding: "0", marginBottom: "3px", backgroundColor: props.themeAlgorithm.includes("dark") ? "black" : "white"}} >
460-
{props.requiredEnableMfa || (Setting.isMobile() ?
461-
<React.Fragment>
462-
<Drawer title={i18next.t("general:Close")} placement="left" open={menuVisible} onClose={onClose}>
457+
<Header style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: "0", marginBottom: "4px", backgroundColor: props.themeAlgorithm.includes("dark") ? "black" : "white"}} >
458+
{
459+
props.requiredEnableMfa || (Setting.isMobile() ? (
460+
<React.Fragment>
461+
<Drawer title={i18next.t("general:Close")} placement="left" open={menuVisible} onClose={onClose}>
462+
<Menu
463+
items={getMenuItems()}
464+
mode={"inline"}
465+
selectedKeys={[props.selectedMenuKey]}
466+
style={{lineHeight: "64px"}}
467+
onClick={onClose}
468+
>
469+
</Menu>
470+
</Drawer>
471+
<Button icon={<BarsOutlined />} onClick={showMenu} type="text">
472+
{i18next.t("general:Menu")}
473+
</Button>
474+
</React.Fragment>
475+
) : (
476+
// Padding 1px for Menu Item Highlight border
477+
<div style={{flex: 1, overflow: "hidden", paddingBottom: "1px"}}>
463478
<Menu
479+
onClick={onClose}
464480
items={getMenuItems()}
465-
mode={"inline"}
481+
mode={"horizontal"}
466482
selectedKeys={[props.selectedMenuKey]}
467-
style={{lineHeight: "64px"}}
468-
onClick={onClose}
469-
>
470-
</Menu>
471-
</Drawer>
472-
<Button icon={<BarsOutlined />} onClick={showMenu} type="text">
473-
{i18next.t("general:Menu")}
474-
</Button>
475-
</React.Fragment> :
476-
<Menu
477-
onClick={onClose}
478-
items={getMenuItems()}
479-
mode={"horizontal"}
480-
selectedKeys={[props.selectedMenuKey]}
481-
style={{position: "absolute", left: 0, right: menuStyleRight, backgroundColor: props.themeAlgorithm.includes("dark") ? "black" : "white"}}
482-
/>
483-
)}
484-
{
485-
renderAccountMenu()
483+
style={{backgroundColor: props.themeAlgorithm.includes("dark") ? "black" : "white"}}
484+
/>
485+
</div>
486+
))
486487
}
488+
<div style={{flexShrink: 0}}>
489+
{renderAccountMenu()}
490+
</div>
487491
</Header>
488492
<Content style={{display: "flex", flexDirection: "column"}} >
489493
{isWithoutCard() ?

0 commit comments

Comments
 (0)