Skip to content

Commit 4513e0c

Browse files
mapsandappsIonitronliamdebeasibrandyscarney
authored
fix(item-divider): apply safe area to proper side regardless of direction (#28420)
Issue number: Internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> The safe area for Item Divider would change sides when the direction changed. e.g., if the safe area padding should be on the left, it would be on the left when the direction was LTR but would be on the right when the direction was RTL. It should always be on the left. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - The left safe area padding is on the left side of an Item Divider whether the direction is LTR or RTL. - The right safe area padding is on the right side of an Item Divider whether the direction is LTR or RTL. - Updated LTR and RTL screenshots for item to include an item divider Similar to #28403 but for Item Divider. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> --------- Co-authored-by: ionitron <[email protected]> Co-authored-by: Liam DeBeasi <[email protected]> Co-authored-by: Brandy Carney <[email protected]>
1 parent 8b877f8 commit 4513e0c

14 files changed

+54
-12
lines changed

core/src/components/item-divider/item-divider.scss

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@
3131

3232
@include font-smoothing();
3333
@include margin(0);
34-
@include padding(
35-
var(--padding-top),
36-
var(--padding-end),
37-
var(--padding-bottom),
38-
calc(var(--padding-start) + var(--ion-safe-area-left, 0px))
39-
);
34+
@include padding(var(--padding-top), null, var(--padding-bottom), null);
35+
36+
/* stylelint-disable */
37+
@include ltr() {
38+
padding-right: var(--padding-end);
39+
padding-left: calc(var(--padding-start) + var(--ion-safe-area-left, 0px));
40+
}
41+
42+
@include rtl() {
43+
padding-right: calc(var(--padding-start) + var(--ion-safe-area-right, 0px));
44+
padding-left: var(--padding-end);
45+
}
46+
/* stylelint-enable */
4047

4148
display: flex;
4249

@@ -67,12 +74,19 @@
6774

6875
.item-divider-inner {
6976
@include margin(0);
70-
@include padding(
71-
var(--inner-padding-top),
72-
calc(var(--ion-safe-area-right, 0px) + var(--inner-padding-end)),
73-
var(--inner-padding-bottom),
74-
var(--inner-padding-start)
75-
);
77+
@include padding(var(--inner-padding-top), null, var(--inner-padding-bottom), null);
78+
79+
/* stylelint-disable */
80+
@include ltr() {
81+
padding-right: calc(var(--ion-safe-area-right, 0px) + var(--inner-padding-end));
82+
padding-left: var(--inner-padding-start);
83+
}
84+
85+
@include rtl() {
86+
padding-right: var(--inner-padding-start);
87+
padding-left: calc(var(--ion-safe-area-left, 0px) + var(--inner-padding-end));
88+
}
89+
/* stylelint-enable */
7690

7791
display: flex;
7892

core/src/components/item-divider/test/basic/item-divider.e2e.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,33 @@ configs().forEach(({ title, screenshot, config }) => {
4646
const divider = page.locator('ion-item-divider');
4747
await expect(divider).toHaveScreenshot(screenshot(`item-divider-icon-start`));
4848
});
49+
50+
/**
51+
* This behavior needs to be tested for all modes & directions
52+
* Safe padding should stay on the same side when the direction changes
53+
*/
54+
test('should have safe area padding', async ({ page }) => {
55+
await page.setContent(
56+
`
57+
<style>
58+
:root {
59+
--ion-safe-area-left: 40px;
60+
--ion-safe-area-right: 20px;
61+
}
62+
</style>
63+
<ion-list>
64+
<ion-item-divider>
65+
<ion-label>Item Divider</ion-label>
66+
<ion-button slot="end">Button</ion-button>
67+
</ion-item-divider>
68+
</ion-list>
69+
`,
70+
config
71+
);
72+
73+
const list = page.locator('ion-list');
74+
75+
await expect(list).toHaveScreenshot(screenshot('item-divider-safe-area'));
76+
});
4977
});
5078
});
2.82 KB
Loading
3.26 KB
Loading
2.61 KB
Loading
2.84 KB
Loading
3.25 KB
Loading
2.63 KB
Loading
2.69 KB
Loading
3.42 KB
Loading

0 commit comments

Comments
 (0)