Skip to content

Commit

Permalink
fix(antd/next): fix components behaviors (#2601)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Dec 9, 2021
1 parent f768143 commit c9d43f0
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/antd/src/form-item/style.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
import 'antd/lib/form/style/index'
import 'antd/lib/tooltip/style/index'
import 'antd/lib/popover/style/index'
import './style.less'
20 changes: 20 additions & 0 deletions packages/core/src/__tests__/field.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { autorun, batch } from '@formily/reactive'
import { createForm } from '../'
import { DataField } from '../types'
import { attach, sleep } from './shared'
Expand Down Expand Up @@ -1834,3 +1835,22 @@ test('single direction linkage effect', async () => {
await input2.onInput('321')
expect(input2.value).toBe('321')
})

test('path change will update computed value', () => {
const form = attach(createForm())

const input = form.createField({
name: 'input',
})

const value = jest.fn()

autorun(() => {
value(input.value)
})
batch(() => {
input.makeIndexes('select')
input.value = '123'
})
expect(value).nthCalledWith(2, '123')
})
1 change: 1 addition & 0 deletions packages/core/src/models/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class Field<
protected makeObservable() {
if (this.designable) return
define(this, {
path: observable.ref,
title: observable.ref,
description: observable.ref,
dataSource: observable.ref,
Expand Down
10 changes: 10 additions & 0 deletions packages/next/docs/components/ArrayCollapse.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Input,
ArrayCollapse,
FormButtonGroup,
Radio,
Submit,
} from '@formily/next'
import { createForm } from '@formily/core'
Expand All @@ -21,6 +22,7 @@ import { Button } from '@alifd/next'

const SchemaField = createSchemaField({
components: {
Radio,
FormItem,
Input,
ArrayCollapse,
Expand Down Expand Up @@ -86,6 +88,14 @@ export default () => {
required
x-component="Input"
/>
<SchemaField.String
name="radio"
x-decorator="FormItem"
title="Radio"
enum={[1, 2]}
required
x-component="Radio.Group"
/>
<SchemaField.Void x-component="ArrayCollapse.Remove" />
<SchemaField.Void x-component="ArrayCollapse.MoveUp" />
<SchemaField.Void x-component="ArrayCollapse.MoveDown" />
Expand Down
1 change: 1 addition & 0 deletions packages/next/docs/components/ArrayItems.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default () => {
</SchemaField.Void>
<SchemaField.Void
x-component="ArrayItems.Addition"
x-component-props={{ method: 'unshift' }}
title="娣诲姞鏉$洰"
/>
</SchemaField.Array>
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/array-collapse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const ArrayCollapse: ComposedArrayCollapse = observer(
return (
<Collapse
{...props}
onChange={() => {}}
expandedKeys={expandKeys.map(String)}
onExpand={(keys: string[]) => setExpandKeys(toArr(keys).map(Number))}
className={cls(`${prefixCls}-item`, props.className)}
Expand Down Expand Up @@ -185,6 +186,7 @@ export const ArrayCollapse: ComposedArrayCollapse = observer(
<Collapse.Panel
{...props}
{...panelProps}
onChange={() => {}}
key={index}
title={title()}
>
Expand Down

0 comments on commit c9d43f0

Please sign in to comment.