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 <hi@ionicframework.com>
Co-authored-by: Amanda Johnston <90629384+amandaejohnston@users.noreply.github.com>
Co-authored-by: Brandy Carney <brandyscarney@users.noreply.github.com>
This commit is contained in:
Shawn Taylor
2023-11-02 10:15:47 -04:00
committed by GitHub
parent b7d1a5c86b
commit ed040b09e9
32 changed files with 71 additions and 18 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -203,14 +203,21 @@
.item-native { .item-native {
@include border-radius(var(--border-radius)); @include border-radius(var(--border-radius));
@include margin(0); @include margin(0);
@include padding( @include padding(var(--padding-top), null, var(--padding-bottom));
var(--padding-top),
var(--padding-end),
var(--padding-bottom),
calc(var(--padding-start) + var(--ion-safe-area-left, 0px))
);
@include text-inherit(); @include text-inherit();
/* stylelint-disable */
@include ltr() {
padding-right: var(--padding-end);
padding-left: calc(var(--padding-start) + var(--ion-safe-area-left, 0px));
}
@include rtl() {
padding-right: calc(var(--padding-start) + var(--ion-safe-area-right, 0px));
padding-left: var(--padding-end);
}
/* stylelint-enable */
display: flex; display: flex;
position: relative; position: relative;
@ -261,12 +268,19 @@ button, a {
.item-inner { .item-inner {
@include margin(0); @include margin(0);
@include padding( @include padding(var(--inner-padding-top), null, var(--inner-padding-bottom));
var(--inner-padding-top),
calc(var(--ion-safe-area-right, 0px) + var(--inner-padding-end)), /* stylelint-disable */
var(--inner-padding-bottom), @include ltr() {
var(--inner-padding-start) padding-right: calc(var(--ion-safe-area-right, 0px) + var(--inner-padding-end));
); padding-left: var(--inner-padding-start);
}
@include rtl() {
padding-right: var(--inner-padding-start);
padding-left: calc(var(--ion-safe-area-left, 0px) + var(--inner-padding-end));
}
/* stylelint-enable */
display: flex; display: flex;
@ -295,12 +309,19 @@ button, a {
.item-bottom { .item-bottom {
@include margin(0); @include margin(0);
@include padding( @include padding(0, null);
0,
var(--inner-padding-end), /* stylelint-disable */
0, @include ltr() {
calc(var(--padding-start) + var(--ion-safe-area-left, 0px)) padding-left: calc(var(--padding-start) + var(--ion-safe-area-left, 0px));
); padding-right: calc(var(--inner-padding-end) + var(--ion-safe-area-right, 0px));
}
@include rtl() {
padding-left: calc(var(--inner-padding-end) + var(--ion-safe-area-left, 0px));
padding-right: calc(var(--padding-start) + var(--ion-safe-area-right, 0px));
}
/* stylelint-enable */
display: flex; display: flex;

View File

@ -10,5 +10,37 @@ configs().forEach(({ title, screenshot, config }) => {
await expect(page).toHaveScreenshot(screenshot(`item-diff`)); await expect(page).toHaveScreenshot(screenshot(`item-diff`));
}); });
/**
* This behavior needs to be tested for all modes & directions
* Safe padding should stay on the same side when the direction changes
*/
test('should have safe area padding', async ({ page }) => {
await page.setContent(
`
<style>
:root {
--ion-safe-area-left: 40px;
--ion-safe-area-right: 20px;
}
</style>
<ion-list>
<ion-item>
<ion-label>Item with helper</ion-label>
<div slot="helper">Helper</div>
</ion-item>
<ion-item>
<ion-label> Single line text that should have ellipses when it doesn't all fit in the item</ion-label>
</ion-item>
</ion-list>
`,
config
);
const list = page.locator('ion-list');
await expect(list).toHaveScreenshot(screenshot('item-safe-area'));
});
}); });
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB