Skip to content

Commit

Permalink
fix(next/designable-antd): fix Select bug && designable-antd spelling…
Browse files Browse the repository at this point in the history
… error (#1934)

* fix(next): fix Select cannot be selected when children is empty

* fix(designable-antd): fix English spelling error
  • Loading branch information
Grapedge authored Aug 3, 2021
1 parent 65259a0 commit 739e8c1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion designable/antd/playground/widgets/ActionsWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const ActionsWidget = observer(() => (
value={GlobalRegistry.getDesignerLanguage()}
optionType="button"
options={[
{ label: 'Engligh', value: 'en-us' },
{ label: 'English', value: 'en-us' },
{ label: '简体中文', value: 'zh-cn' },
]}
onChange={(e) => {
Expand Down
24 changes: 22 additions & 2 deletions packages/next/src/select/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
import { connect, mapReadPretty, mapProps } from '@formily/react'
import { isVoidField } from '@formily/core'
import { Select as NextSelect } from '@alifd/next'
import { PreviewText } from '../preview-text'
import { mapSize, mapStatus } from '../__builtins__'

const patchDataSource = (dataSource: any = []) => {
const removeEmptyChildren = (data: any) => {
const result = { ...data }
if (!result.children || result.children.length === 0) {
delete result.children
} else {
result.children = result.children.map(removeEmptyChildren)
}
return result
}
return dataSource.map(removeEmptyChildren)
}

export const Select = connect(
NextSelect,
mapProps(
{
dataSource: true,
(props, field) => {
if (isVoidField(field)) {
return props
}
return {
...props,
dataSource: patchDataSource(props.dataSource ?? field?.dataSource),
}
},
mapSize,
mapStatus
Expand Down

0 comments on commit 739e8c1

Please sign in to comment.