Skip to content

Commit 264dec7

Browse files
authored
fix(array-table): fix input box will be out of focus after each input (#42)
1 parent c27f344 commit 264dec7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/components/src/array-table/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const useArrayTableSources = () => {
134134

135135
return parseArrayItems(schema.items)
136136
}
137-
const indexKey = '__index__'
137+
const indexKey = '__DO_NOT_USE_THIS_PROPERTY_index__'
138138
const useArrayTableColumns = (
139139
dataSource: any[],
140140
field: ArrayField,
@@ -152,7 +152,7 @@ const useArrayTableColumns = (
152152
const index = record[indexKey]
153153

154154
const children = (
155-
<ArrayBase.Item index={index} record={record}>
155+
<ArrayBase.Item index={index} record={() => field?.value?.[index]}>
156156
<RecursionField
157157
schema={schema}
158158
name={index}
@@ -342,9 +342,10 @@ const InternalArrayTable: ReactFC<TableProps<any>> = observer(
342342
const field = useField<ArrayField>()
343343
const prefixCls = usePrefixCls('formily-array-table')
344344
const [wrapSSR, hashId] = useStyle(prefixCls)
345-
const dataSource = Array.isArray(field.value)
346-
? field.value.slice().map((x, idx) => ({ [indexKey]: idx, ...x }))
347-
: []
345+
const dataSource = Array.isArray(field.value) ? field.value.slice() : []
346+
dataSource.forEach((item, index) => {
347+
item[indexKey] = index
348+
})
348349
const sources = useArrayTableSources()
349350
const columns = useArrayTableColumns(dataSource, field, sources)
350351
const pagination = isBool(props.pagination) ? {} : props.pagination

0 commit comments

Comments
 (0)