docs(changelog): menu render-icon change

This commit is contained in:
07akioni 2021-07-30 00:05:17 +08:00
parent 153ecc9030
commit 7cb72375aa
4 changed files with 8 additions and 5 deletions

View File

@ -5,6 +5,7 @@
### Feats
- `n-scrollbar` add `scrollbarWidth`, `scrollbarHeight` and `scrollbarBorderRadius` common theme variables, closes [#649](https://github.com/TuSimple/naive-ui/issues/649).
- `n-menu` doesn't should icon placeholder when `render-icon` returns falsy value, closes [#722](https://github.com/TuSimple/naive-ui/issues/722).
## 2.15.11 (2021-07-29)

View File

@ -1,8 +1,11 @@
# CHANGELOG
## Pending
### Feats
- `n-scrollbar` 增加 `scrollbarWidth`、`scrollbarHeight` 和 `scrollbarBorderRadius` 公共主题变量,关闭 [#649](https://github.com/TuSimple/naive-ui/issues/649)
- `n-menu``render-icon` 返回 falsy 值的时候不渲染 icon 的占位符,关闭 [#722](https://github.com/TuSimple/naive-ui/issues/722)
## 2.15.11 (2021-07-29)

View File

@ -87,7 +87,7 @@ export default defineComponent({
style={this.iconStyle}
role="none"
>
{icon === true ? render(this.icon) : icon}
{icon}
</div>
)}
<div class={`${clsPrefix}-menu-item-content-header`} role="none">

View File

@ -49,8 +49,7 @@ describe('n-menu', () => {
},
{
label: 'mojito',
key: 'mojito',
icon: () => h(NIcon, null, { default: () => h(HappyOutline) })
key: 'mojito'
},
{
label: 'initialj',
@ -59,7 +58,7 @@ describe('n-menu', () => {
]
function renderMenuIcon (option: any): any {
if (option.key === 'fantasy') return true // render indent
if (option.key === 'mojito') return true // keep menu option icon render
if (option.key === 'mojito') return true // render indent
if (option.key === 'initialj') return null // don't render
return h(NIcon, null, { default: () => h(HappyOutline) }) // render this
}
@ -70,7 +69,7 @@ describe('n-menu', () => {
}
})
expect(wrapper.findAll('.n-menu-item-content__icon').length).toBe(3)
expect(wrapper.findAll('.n-icon').length).toBe(2)
expect(wrapper.findAll('.n-icon').length).toBe(1)
})
it('should tooltip work with `render-label` props', async () => {