Skip to content
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

Fix(form): Collpsed in FormItemGi does not work #1166

Merged
merged 2 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Fix `n-dynamic-tags` add button is not disabled when it is disabled.
- Fix `n-select` closes menu when enter key is pressed in filterable mode without options data.
- Fix `n-auto-complete`'s `children` prop can't use `AutoCompleteOption` type.
- Fix `n-gi`'s `collapsed` does not work in `n-form-item-gi`, closes [#1160](https://github.com/TuSimple/naive-ui/issues/1160).

## 2.18.1 (2021-09-08)

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- 修复 `n-dynamic-tags` 禁用时 add 按钮未被禁用
- 修复 `n-select` 在 filterable 并且菜单无数据是按下 enter 导致菜单关闭
- 修复 `n-auto-complete` 的 `children` 属性不允许使用 `AutoCompleteOption` 类型
- 修复 `n-gi` 的 `collapsed` 在 `n-form-item-gi` 中切换无法生效问题,关闭 [#1160](https://github.com/TuSimple/naive-ui/issues/1160)

## 2.18.1 (2021-09-08)

Expand Down
9 changes: 6 additions & 3 deletions src/form/src/FormItemGridItem.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h, ref, defineComponent } from 'vue'
import { h, ref, defineComponent, getCurrentInstance } from 'vue'
import NGridItem, {
gridItemProps,
gridItemPropKeys
GridItemVNodeProps
} from '../../grid/src/GridItem'
import { keep, keysOf } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
Expand Down Expand Up @@ -42,7 +42,10 @@ export default defineComponent({
}
},
render () {
return h(NGridItem, keep(this.$props, gridItemPropKeys), {
const self = getCurrentInstance()
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const gridItemProps = self!.vnode.props as GridItemVNodeProps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这几行得写到 setup里面么

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

写在这个位置看起来没啥毛病。

不过也是有问题的,就是说把 formItemProps 也传给 gridItemProps 了,得想办法改一下。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self!.vnode.props 打印出来是不包含formItemProps的, 只有GridItemVNodeProps定义的几个类型值

return h(NGridItem, gridItemProps, {
default: () => {
const itemProps = keep(this.$props, formItemPropKeys)
return h(
Expand Down
6 changes: 2 additions & 4 deletions src/grid/src/GridItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { ExtractPublicPropTypes } from '../../_utils'

export const defaultSpan = 1

interface GridItemVNodeProps {
export interface GridItemVNodeProps {
privateOffset?: number
privateSpan?: number
privateColStart?: number
Expand Down Expand Up @@ -87,9 +87,7 @@ export default defineComponent({
render () {
return (
<div
style={
([this.itemStyle, this.deriveStyle()] as unknown) as CSSProperties
}
style={[this.itemStyle, this.deriveStyle()] as unknown as CSSProperties}
07akioni marked this conversation as resolved.
Show resolved Hide resolved
>
{renderSlot(this.$slots, 'default', { overflow: this.overflow })}
</div>
Expand Down