Skip to content

Commit 32b4fb2

Browse files
authored
fix(ui5-form): propagate itemSpacing properly (#11312)
Propagate itemSpacing properly from Form to Form items Fixes: #11307
1 parent 6f1bf67 commit 32b4fb2

File tree

6 files changed

+35
-5
lines changed

6 files changed

+35
-5
lines changed

packages/fiori/test/pages/FCL.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
<ui5-segmented-button id="sb">
137137
<ui5-toggle-button icon="employee" pressed>Small</ui5-toggle-button>
138138
<ui5-toggle-button>Medium</ui5-toggle-button>
139-
<ui5-toggle-button>Largr</ui5-toggle-button>
139+
<ui5-toggle-button>Large</ui5-toggle-button>
140140
</ui5-segmented-button>
141141
</div>
142142
</div>

packages/fiori/test/pages/Wizard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ <h2>Wizard non-standard 3</h2>
631631
<ui5-segmented-button id="sb2">
632632
<ui5-toggle-button icon="employee" pressed>Small</ui5-toggle-button>
633633
<ui5-toggle-button>Medium</ui5-toggle-button>
634-
<ui5-toggle-button>Largr</ui5-toggle-button>
634+
<ui5-toggle-button>Large</ui5-toggle-button>
635635
</ui5-segmented-button>
636636
</div>
637637
</div>

packages/fiori/test/pages/WizardPageMode_test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<ui5-segmented-button>
118118
<ui5-toggle-button icon="employee" pressed>Small</ui5-toggle-button>
119119
<ui5-toggle-button>Medium</ui5-toggle-button>
120-
<ui5-toggle-button>Largr</ui5-toggle-button>
120+
<ui5-toggle-button>Large</ui5-toggle-button>
121121
</ui5-segmented-button>
122122
</div>
123123
</div>

packages/fiori/test/pages/Wizard_test.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
<ui5-segmented-button id="sb">
121121
<ui5-toggle-button icon="employee" pressed>Small</ui5-toggle-button>
122122
<ui5-toggle-button>Medium</ui5-toggle-button>
123-
<ui5-toggle-button>Largr</ui5-toggle-button>
123+
<ui5-toggle-button>Large</ui5-toggle-button>
124124
</ui5-segmented-button>
125125
</div>
126126
</div>
@@ -285,7 +285,7 @@
285285
<ui5-segmented-button>
286286
<ui5-toggle-button icon="employee" pressed>Small</ui5-toggle-button>
287287
<ui5-toggle-button>Medium</ui5-toggle-button>
288-
<ui5-toggle-button>Largr</ui5-toggle-button>
288+
<ui5-toggle-button>Large</ui5-toggle-button>
289289
</ui5-segmented-button>
290290
</div>
291291
</div>

packages/main/cypress/specs/Form.cy.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,27 @@ describe("General API", () => {
199199
.and("have.prop", "emptySpanXl", 1);
200200
});
201201

202+
it("tests calculated state of Form item-spacing='Large'", () => {
203+
cy.mount(<Form id="addressForm" item-spacing="Large">
204+
<FormGroup id="formGroup">
205+
<FormItem id="formItem">
206+
<Label slot="labelContent">Name:</Label>
207+
<Text>Red Point Stores</Text>
208+
</FormItem>
209+
210+
<FormItem>
211+
<Label slot="labelContent">Country:</Label>
212+
<Text>Germany</Text>
213+
</FormItem>
214+
</FormGroup>
215+
</Form>);
216+
217+
cy.get("#formGroup")
218+
.should("have.prop", "itemSpacing", "Large");
219+
cy.get("#formItem")
220+
.should("have.prop", "itemSpacing", "Large");
221+
});
222+
202223
it("tests calculated state of two FormGroups in layout='S1 M2 L3 XL4'", () => {
203224
cy.mount(<Form headerText="WebC :: Supplier 2gr (S1 M2 L3 XL4)" layout="S1 M2 L3 XL4">
204225
<FormGroup id="testFormGroup4" headerText="Address">

packages/main/src/Form.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ class Form extends UI5Element {
342342

343343
// Define how many columns a group should take.
344344
this.setGroupsColSpan();
345+
346+
// Set item spacing
347+
this.setItemSpacing();
345348
}
346349

347350
onAfterRendering() {
@@ -489,6 +492,12 @@ class Form extends UI5Element {
489492
return index === 0 ? MIN_COL_SPAN + (delta - groups) + 1 : MIN_COL_SPAN + 1;
490493
}
491494

495+
setItemSpacing() {
496+
this.items.forEach((item: IFormItem) => {
497+
item.itemSpacing = this.itemSpacing;
498+
});
499+
}
500+
492501
get hasGroupItems(): boolean {
493502
return this.items.some((item: IFormItem) => item.isGroup);
494503
}

0 commit comments

Comments
 (0)