Merge pull request #1428 from 2betop/appnav

收起状态导航菜单不可点击跳转问题修复
This commit is contained in:
RickCole 2021-01-22 17:19:59 +08:00 committed by GitHub
commit 39d38c03d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View File

@ -66,7 +66,15 @@ export class AsideNav extends React.Component<AsideNavProps, AsideNavState> {
<ul className={cx('AsideNav-subList')}> <ul className={cx('AsideNav-subList')}>
{link.label ? ( {link.label ? (
<li key="subHeader" className={cx('AsideNav-subHeader')}> <li key="subHeader" className={cx('AsideNav-subHeader')}>
<a>{link.label}</a> {renderLink(
{
...link,
children: undefined
},
'subHeader',
{},
depth
)}
</li> </li>
) : null} ) : null}
{link.children.map((link, key) => {link.children.map((link, key) =>
@ -183,6 +191,7 @@ export class AsideNav extends React.Component<AsideNavProps, AsideNavState> {
toggleExpand: this.toggleExpand, toggleExpand: this.toggleExpand,
depth, depth,
classnames: cx, classnames: cx,
subHeader: key === 'subHeader',
...others ...others
}); });

View File

@ -256,20 +256,17 @@ export default class App extends React.Component<AppProps, object> {
{asideBefore ? render('aside-before', asideBefore) : null} {asideBefore ? render('aside-before', asideBefore) : null}
<AsideNav <AsideNav
navigations={store.navigations} navigations={store.navigations}
renderLink={({ renderLink={(
link, {link, active, toggleExpand, classnames: cx, depth, subHeader}: any,
active, key: any
toggleExpand, ) => {
classnames: cx,
depth
}: any) => {
let children = []; let children = [];
if (link.visible === false) { if (link.visible === false) {
return null; return null;
} }
if (link.children && link.children.length) { if (!subHeader && link.children && link.children.length) {
children.push( children.push(
<span <span
key="expand-toggle" key="expand-toggle"
@ -292,11 +289,11 @@ export default class App extends React.Component<AppProps, object> {
</b> </b>
); );
if (link.icon) { if (!subHeader && link.icon) {
children.push( children.push(
<i key="icon" className={cx(`AsideNav-itemIcon`, link.icon)} /> <i key="icon" className={cx(`AsideNav-itemIcon`, link.icon)} />
); );
} else if (store.folded && depth === 1) { } else if (store.folded && depth === 1 && !subHeader) {
children.push( children.push(
<i <i
key="icon" key="icon"