Skip to content

Commit 3ab4c26

Browse files
authored
Merge pull request #166 from ownego/dev
Fix: FormGroup item wrapper in the loop
2 parents ed814c4 + b9bcea6 commit 3ab4c26

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/components/FormLayout/README.stories.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ export const FormLayoutGroup = (args, { argTypes }) => ({
9696
},
9797
template: `<FormLayout>
9898
<FormGroup>
99-
<TextField v-model="min" type="number">
99+
<TextField v-model="min" autoComplete="off" type="number">
100100
<template #label>Minimum order</template>
101101
</TextField>
102-
<TextField v-model="max" type="number">
102+
<TextField v-model="max" autoComplete="off" type="number">
103103
<template #label>Maximum order</template>
104104
</TextField>
105105
</FormGroup>
@@ -117,10 +117,10 @@ export const FormLayoutGroup = (args, { argTypes }) => ({
117117
code: dedent`
118118
<FormLayout>
119119
<FormGroup>
120-
<TextField v-model="min" type="number">
120+
<TextField v-model="min" autoComplete="off" type="number">
121121
<template #label>Minimum order</template>
122122
</TextField>
123-
<TextField v-model="max" type="number">
123+
<TextField v-model="max" autoComplete="off" type="number">
124124
<template #label>Maximum order</template>
125125
</TextField>
126126
</FormGroup>
@@ -146,16 +146,16 @@ export const FormGroupCondensed = (args) => ({
146146
},
147147
template: `<FormLayout>
148148
<FormGroup condensed>
149-
<TextField>
149+
<TextField autoComplete="off">
150150
<template #label>Length</template>
151151
</TextField>
152-
<TextField>
152+
<TextField autoComplete="off">
153153
<template #label>Width</template>
154154
</TextField>
155-
<TextField>
155+
<TextField autoComplete="off">
156156
<template #label>Height</template>
157157
</TextField>
158-
<TextField>
158+
<TextField autoComplete="off">
159159
<template #label>Unit</template>
160160
</TextField>
161161
</FormGroup>
@@ -172,16 +172,16 @@ export const FormGroupCondensed = (args) => ({
172172
code: dedent`
173173
<FormLayout>
174174
<FormGroup condensed>
175-
<TextField>
175+
<TextField autoComplete="off">
176176
<template #label>Length</template>
177177
</TextField>
178-
<TextField>
178+
<TextField autoComplete="off">
179179
<template #label>Width</template>
180180
</TextField>
181-
<TextField>
181+
<TextField autoComplete="off">
182182
<template #label>Height</template>
183183
</TextField>
184-
<TextField>
184+
<TextField autoComplete="off">
185185
<template #label>Unit</template>
186186
</TextField>
187187
</FormGroup>

src/components/FormLayout/components/Group/Group.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@ div(
1313
slot(v-if="slots.title", name="title")
1414
template(v-else) {{ title }}
1515
div(:class="styles.Items")
16-
template(v-if="slots.default")
17-
Item(
18-
v-for="(item, index) in slots.default()",
16+
template(v-if="slots.default && hasSlot(slots.default)")
17+
template(
18+
v-for="item, index in slots.default()",
1919
:key="index",
2020
)
21-
component(:is="item")
21+
Item(
22+
v-if="item.type.toString() === 'Symbol(Fragment)' && item.el === null && item.children",
23+
v-for="child, childIndex in item.children",
24+
:key="`${index}-${childIndex.toString()}`",
25+
)
26+
component(:is="child")
27+
Item(v-else)
28+
component(:is="item")
2229
slot(v-else)
2330
div(
2431
v-if="slots['help-text'] || helpText",
@@ -33,6 +40,7 @@ div(
3340
import { computed, useSlots } from 'vue';
3441
import { classNames } from 'polaris/polaris-react/src/utilities/css';
3542
import { Item } from '../Item';
43+
import { hasSlot } from '@/utilities/has-slot';
3644
import styles from '@/classes/FormLayout.json';
3745
import { UseUniqueId } from '@/use';
3846

0 commit comments

Comments
 (0)