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(element): fix select label error #2202

Merged
merged 2 commits into from
Sep 21, 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
5 changes: 3 additions & 2 deletions packages/element/docs/demos/guide/select/template-async.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
},
},
]"
:enum="[
:dataSource="[
{ label: '发请求1', value: 1 },
{ label: '发请求2', value: 2 },
]"
/>
<Field
name="[Select]"
name="select"
title="异步选择框"
:decorator="[FormItem]"
:component="[
Expand Down Expand Up @@ -57,6 +57,7 @@ const form = createForm({
useAsyncDataSource('select', async (field) => {
const linkage = field.query('linkage').get('value')
if (!linkage) return []

return new Promise((resolve) => {
setTimeout(() => {
if (linkage === 1) {
Expand Down
6 changes: 6 additions & 0 deletions packages/element/src/form-layout/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import '../__builtins__/styles/common.scss';

.#{$formily-prefix}-form-inline {
display: flex;
flex-wrap: wrap;
}
15 changes: 5 additions & 10 deletions packages/element/src/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ import type {
Option as ElOptionProps,
} from 'element-ui'
import { Select as ElSelect, Option as ElOption } from 'element-ui'
import { resolveComponent, SlotTypes } from '../__builtins__'
import { resolveComponent } from '../__builtins__'

export type SelectProps = ElSelectProps & {
options?: Array<
Omit<ElOptionProps, 'label'> & {
label: SlotTypes
}
>
options?: Array<ElOptionProps>
}

const SelectOption = defineComponent<SelectProps>({
Expand All @@ -31,10 +27,10 @@ const SelectOption = defineComponent<SelectProps>({
if (typeof option === 'string') {
return h(
ElOption,
{ props: { value: option } },
{ props: { value: option, label: option } },
{
default: () => [
resolveComponent(slots?.option ?? option, { option }),
resolveComponent(slots?.option, { option }),
],
}
)
Expand All @@ -44,12 +40,11 @@ const SelectOption = defineComponent<SelectProps>({
{
props: {
...option,
label: '',
},
},
{
default: () => [
resolveComponent(slots?.option ?? option.label, {
resolveComponent(slots?.option, {
option,
}),
],
Expand Down