-
Notifications
You must be signed in to change notification settings - Fork 99
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
Hotfix/menu(#2618) #2620
Hotfix/menu(#2618) #2620
Changes from 2 commits
43fedf3
e790773
6a15028
1f82d70
863bcde
dca2329
3757fed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,11 +90,11 @@ export const MenuItem = forwardRef<HTMLLIElement | null, MenuItemProps>( | |
})} | ||
onClick={() => { | ||
if (isArrayNonEmpty(children)) { | ||
if (clickSubMenu) { | ||
if (!disabled && clickSubMenu) { | ||
clickSubMenu(id) | ||
} | ||
} else { | ||
if (clickMenu) { | ||
if (!disabled && clickMenu) { | ||
// @ts-ignore | ||
clickMenu(id, raw) | ||
} | ||
|
@@ -121,7 +121,7 @@ export const MenuItem = forwardRef<HTMLLIElement | null, MenuItemProps>( | |
placement === 'vertical' && | ||
expandedType === 'collapse' && | ||
!showAllSubMenus && | ||
(expandedIds?.includes(id) ? ( | ||
(!disabled && expandedIds?.includes(id) ? ( | ||
<Arrow prefixCls={`${prefixCls}-item`} direction="up" /> | ||
) : ( | ||
<Arrow prefixCls={`${prefixCls}-item`} direction="down" /> | ||
|
@@ -144,7 +144,7 @@ export const MenuItem = forwardRef<HTMLLIElement | null, MenuItemProps>( | |
{hasChildren && | ||
placement === 'horizontal' && | ||
level === 1 && | ||
(expandedIds?.includes(id) ? ( | ||
(!disabled && expandedIds?.includes(id) ? ( | ||
<Arrow prefixCls={`${prefixCls}-item`} direction="up" /> | ||
) : ( | ||
<Arrow prefixCls={`${prefixCls}-item`} direction="down" /> | ||
|
@@ -156,7 +156,7 @@ export const MenuItem = forwardRef<HTMLLIElement | null, MenuItemProps>( | |
!mini && | ||
!showAllSubMenus && | ||
expandedType === 'collapse' ? ( | ||
<Expander visible={!!expandedIds?.includes(id)}> | ||
<Expander visible={!disabled && !!expandedIds?.includes(id)}> | ||
<ul className={`${prefixCls}-submenu`}> | ||
{children!.map((child) => ( | ||
<MenuItem | ||
|
@@ -323,15 +323,14 @@ export const MenuItem = forwardRef<HTMLLIElement | null, MenuItemProps>( | |
{child.children.map((item) => ( | ||
<div | ||
onClick={() => { | ||
if (clickMenu) { | ||
clickMenu(item.id, item) | ||
} | ||
if (closePopper) { | ||
closePopper(id) | ||
if(!item.disabled) { | ||
clickMenu && clickMenu(item.id, item) | ||
closePopper && closePopper(id) | ||
} | ||
}} | ||
className={cx(`${prefixCls}-item`, { | ||
[`${prefixCls}-item--active`]: activeId === item.id, | ||
[`${prefixCls}-item--disabled`]: item.disabled | ||
})} | ||
key={item.id} | ||
> | ||
|
@@ -431,13 +430,12 @@ export const MenuItem = forwardRef<HTMLLIElement | null, MenuItemProps>( | |
<div | ||
className={cx(`${prefixCls}-item`, { | ||
[`${prefixCls}-item--active`]: activeId === item.id, | ||
[`${prefixCls}-item--disabled`]: item.disabled | ||
})} | ||
onClick={() => { | ||
if (clickMenu) { | ||
clickMenu(item.id, item) | ||
} | ||
if (closePopper) { | ||
closePopper(id) | ||
if(!item.disabled) { | ||
clickMenu && clickMenu(item.id, item) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
closePopper && closePopper(id) | ||
} | ||
}} | ||
key={item.id} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
@import '~@hi-ui/core-css/lib/index.scss'; | ||
|
||
$prefix: '#{$component-prefix}-menu' !default; | ||
$disabled-color: var(--hi-v4-color-gray-400, #c9ced6) !default; | ||
|
||
@mixin menu-item-disabled() { | ||
color: $disabled-color; | ||
cursor: not-allowed; | ||
} | ||
|
||
.#{$prefix}-fat-menu { | ||
background-color: use-color-static('white'); | ||
|
@@ -41,6 +47,10 @@ $prefix: '#{$component-prefix}-menu' !default; | |
&:not(.#{$prefix}-item--active):hover { | ||
background-color: use-color('gray', 100); | ||
} | ||
|
||
&--disabled { | ||
@include menu-item-disabled; | ||
} | ||
} | ||
|
||
ul { | ||
|
@@ -92,6 +102,10 @@ $prefix: '#{$component-prefix}-menu' !default; | |
&:not(.#{$prefix}-item__inner--active):hover { | ||
background-color: use-color('gray', 100); | ||
} | ||
|
||
&--disabled { | ||
@include menu-item-disabled; | ||
} | ||
} | ||
|
||
&__content { | ||
|
@@ -143,6 +157,10 @@ $prefix: '#{$component-prefix}-menu' !default; | |
height: 100%; | ||
flex-shrink: 0; | ||
} | ||
|
||
&--disabled { | ||
@include menu-item-disabled; | ||
} | ||
} | ||
|
||
&__wrapper { | ||
|
@@ -220,6 +238,18 @@ $prefix: '#{$component-prefix}-menu' !default; | |
white-space: nowrap; | ||
max-width: none; | ||
} | ||
|
||
&--disabled { | ||
@include menu-item-disabled; | ||
|
||
.#{$prefix}-item__inner.#{$prefix}-item__inner { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2个类选择器名字一样,是否多余 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个是为了增加权限,否则样式无法复写 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议可以按照非禁用状态下的样式结构进行覆写,更利于代码阅读,例如: |
||
border-bottom: 0; | ||
|
||
.#{$prefix}-item__content { | ||
color: $disabled-color; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
@@ -309,6 +339,10 @@ $prefix: '#{$component-prefix}-menu' !default; | |
white-space: nowrap; | ||
text-indent: 0.5px; | ||
} | ||
|
||
&--disabled { | ||
@include menu-item-disabled; | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这2行代码建议使用可选链,代码更简洁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done