Skip to content

Commit

Permalink
fix(array-table): fix input box will be out of focus after each input (
Browse files Browse the repository at this point in the history
  • Loading branch information
zybzzc authored Jul 5, 2024
1 parent c27f344 commit 264dec7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/components/src/array-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const useArrayTableSources = () => {

return parseArrayItems(schema.items)
}
const indexKey = '__index__'
const indexKey = '__DO_NOT_USE_THIS_PROPERTY_index__'
const useArrayTableColumns = (
dataSource: any[],
field: ArrayField,
Expand All @@ -152,7 +152,7 @@ const useArrayTableColumns = (
const index = record[indexKey]

const children = (
<ArrayBase.Item index={index} record={record}>
<ArrayBase.Item index={index} record={() => field?.value?.[index]}>
<RecursionField
schema={schema}
name={index}
Expand Down Expand Up @@ -342,9 +342,10 @@ const InternalArrayTable: ReactFC<TableProps<any>> = observer(
const field = useField<ArrayField>()
const prefixCls = usePrefixCls('formily-array-table')
const [wrapSSR, hashId] = useStyle(prefixCls)
const dataSource = Array.isArray(field.value)
? field.value.slice().map((x, idx) => ({ [indexKey]: idx, ...x }))
: []
const dataSource = Array.isArray(field.value) ? field.value.slice() : []
dataSource.forEach((item, index) => {
item[indexKey] = index
})
const sources = useArrayTableSources()
const columns = useArrayTableColumns(dataSource, field, sources)
const pagination = isBool(props.pagination) ? {} : props.pagination
Expand Down

1 comment on commit 264dec7

@xxi-arch
Copy link

Choose a reason for hiding this comment

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

DO_NOT_USE_THIS_PROPERTY_index 生成的值里会多一个 这个字段

https://codesandbox.io/p/sandbox/hungry-lamport-fphqj2?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clyi27rdw0006356kj3g226ok%2522%252C%2522sizes%2522%253A%255B100%252C0%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clyi27rdw0002356k12mdnzxx%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clyi27rdw0003356ksdym4iua%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clyi27rdw0005356kymkuhmh6%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clyi27rdw0002356k12mdnzxx%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clyi27rdv0001356knf6tejlm%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Findex.html%2522%257D%255D%252C%2522id%2522%253A%2522clyi27rdw0002356k12mdnzxx%2522%252C%2522activeTabId%2522%253A%2522clyi27rdv0001356knf6tejlm%2522%257D%252C%2522clyi27rdw0005356kymkuhmh6%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clyi27rdw0004356kdrnv2exw%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522path%2522%253A%2522%252F%2522%257D%255D%252C%2522id%2522%253A%2522clyi27rdw0005356kymkuhmh6%2522%252C%2522activeTabId%2522%253A%2522clyi27rdw0004356kdrnv2exw%2522%257D%252C%2522clyi27rdw0003356ksdym4iua%2522%253A%257B%2522tabs%2522%253A%255B%255D%252C%2522id%2522%253A%2522clyi27rdw0003356ksdym4iua%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Afalse%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

Please sign in to comment.