Skip to content

Commit ed040b0

Browse files
mapsandappsIonitronaveryjohnstonbrandyscarney
authored
fix(item): apply safe area to proper side regardless of direction (#28403)
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 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 Item whether the direction is LTR or RTL. - The right safe area padding is on the right side of Item whether the direction is LTR or RTL. - There's now a screenshot test for left and right padding for both directions. Note: There is a separate ticket for updating the safe area padding for ion-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: Amanda Johnston <[email protected]> Co-authored-by: Brandy Carney <[email protected]>
1 parent b7d1a5c commit ed040b0

File tree

32 files changed

+71
-18
lines changed

32 files changed

+71
-18
lines changed
2 Bytes
Loading
-28 Bytes
Loading
2 Bytes
Loading
2 Bytes
Loading
-2 Bytes
Loading
1 Byte
Loading

core/src/components/item/item.scss

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,21 @@
203203
.item-native {
204204
@include border-radius(var(--border-radius));
205205
@include margin(0);
206-
@include padding(
207-
var(--padding-top),
208-
var(--padding-end),
209-
var(--padding-bottom),
210-
calc(var(--padding-start) + var(--ion-safe-area-left, 0px))
211-
);
206+
@include padding(var(--padding-top), null, var(--padding-bottom));
212207
@include text-inherit();
213208

209+
/* stylelint-disable */
210+
@include ltr() {
211+
padding-right: var(--padding-end);
212+
padding-left: calc(var(--padding-start) + var(--ion-safe-area-left, 0px));
213+
}
214+
215+
@include rtl() {
216+
padding-right: calc(var(--padding-start) + var(--ion-safe-area-right, 0px));
217+
padding-left: var(--padding-end);
218+
}
219+
/* stylelint-enable */
220+
214221
display: flex;
215222
position: relative;
216223

@@ -261,12 +268,19 @@ button, a {
261268

262269
.item-inner {
263270
@include margin(0);
264-
@include padding(
265-
var(--inner-padding-top),
266-
calc(var(--ion-safe-area-right, 0px) + var(--inner-padding-end)),
267-
var(--inner-padding-bottom),
268-
var(--inner-padding-start)
269-
);
271+
@include padding(var(--inner-padding-top), null, var(--inner-padding-bottom));
272+
273+
/* stylelint-disable */
274+
@include ltr() {
275+
padding-right: calc(var(--ion-safe-area-right, 0px) + var(--inner-padding-end));
276+
padding-left: var(--inner-padding-start);
277+
}
278+
279+
@include rtl() {
280+
padding-right: var(--inner-padding-start);
281+
padding-left: calc(var(--ion-safe-area-left, 0px) + var(--inner-padding-end));
282+
}
283+
/* stylelint-enable */
270284

271285
display: flex;
272286

@@ -295,12 +309,19 @@ button, a {
295309

296310
.item-bottom {
297311
@include margin(0);
298-
@include padding(
299-
0,
300-
var(--inner-padding-end),
301-
0,
302-
calc(var(--padding-start) + var(--ion-safe-area-left, 0px))
303-
);
312+
@include padding(0, null);
313+
314+
/* stylelint-disable */
315+
@include ltr() {
316+
padding-left: calc(var(--padding-start) + var(--ion-safe-area-left, 0px));
317+
padding-right: calc(var(--inner-padding-end) + var(--ion-safe-area-right, 0px));
318+
}
319+
320+
@include rtl() {
321+
padding-left: calc(var(--inner-padding-end) + var(--ion-safe-area-left, 0px));
322+
padding-right: calc(var(--padding-start) + var(--ion-safe-area-right, 0px));
323+
}
324+
/* stylelint-enable */
304325

305326
display: flex;
306327

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,37 @@ configs().forEach(({ title, screenshot, config }) => {
1010

1111
await expect(page).toHaveScreenshot(screenshot(`item-diff`));
1212
});
13+
14+
/**
15+
* This behavior needs to be tested for all modes & directions
16+
* Safe padding should stay on the same side when the direction changes
17+
*/
18+
test('should have safe area padding', async ({ page }) => {
19+
await page.setContent(
20+
`
21+
<style>
22+
:root {
23+
--ion-safe-area-left: 40px;
24+
--ion-safe-area-right: 20px;
25+
}
26+
</style>
27+
<ion-list>
28+
<ion-item>
29+
<ion-label>Item with helper</ion-label>
30+
<div slot="helper">Helper</div>
31+
</ion-item>
32+
33+
<ion-item>
34+
<ion-label> Single line text that should have ellipses when it doesn't all fit in the item</ion-label>
35+
</ion-item>
36+
</ion-list>
37+
`,
38+
config
39+
);
40+
41+
const list = page.locator('ion-list');
42+
43+
await expect(list).toHaveScreenshot(screenshot('item-safe-area'));
44+
});
1345
});
1446
});
6.1 KB
Loading
7.33 KB
Loading

0 commit comments

Comments
 (0)