fix(list-header): apply safe area to proper side regardless of direction (#28371)
Issue number: Internal --------- ## What is the current behavior? The list header adds padding to the "start" side (`padding-left` in LTR and `padding-right` in RTL) based on the value of `--ion-safe-area-left`. It does not account for `--ion-safe-area-right` at all even though the list header can extend to the right side of the content. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - The `--ion-safe-area-left` always applies to the left side of the screen, regardless of direction. This means that in both LTR and RTL it applies as `padding-left`. - Added support for `--ion-safe-area-right` which applies to `padding-right` in both LTR and RTL. - Adds an e2e test which captures the list header with a button to ensure the proper padding is added for the safe area. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information ### Safe Area Left | mode | direction | `main` | `branch` | | ---| ---| ---| ---| | `ios` | `LTR` |  |  | | `ios` | `RTL` |  |  | | `md` | `LTR` |  |  | | `md` | `RTL` |  |  | ### Safe Area Right | mode | direction | `main` | `branch` | | ---| ---| ---| ---| | `ios` | `LTR` |  | | | `ios` | `RTL` |  |  | | `md` |`LTR` |  |  | | `md` |`RTL` |  |  | --------- Co-authored-by: ionitron <hi@ionicframework.com>
@ -9,7 +9,17 @@
|
||||
--color: #{$list-header-ios-color};
|
||||
--border-color: #{$item-ios-border-bottom-color};
|
||||
|
||||
@include padding-horizontal(calc(var(--ion-safe-area-left, 0px) + #{$list-header-ios-padding-start}), null);
|
||||
/* stylelint-disable */
|
||||
@include ltr() {
|
||||
padding-right: var(--ion-safe-area-right);
|
||||
padding-left: calc(var(--ion-safe-area-left, 0px) + #{$list-header-ios-padding-start});
|
||||
}
|
||||
|
||||
@include rtl() {
|
||||
padding-right: calc(var(--ion-safe-area-right, 0px) + #{$list-header-ios-padding-start});
|
||||
padding-left: var(--ion-safe-area-left);
|
||||
}
|
||||
/* stylelint-enable */
|
||||
|
||||
position: relative;
|
||||
|
||||
|
@ -9,7 +9,17 @@
|
||||
--color: #{$list-header-md-color};
|
||||
--border-color: #{$item-md-border-bottom-color};
|
||||
|
||||
@include padding-horizontal(calc(var(--ion-safe-area-left, 0) + #{$list-header-md-padding-start}), null);
|
||||
/* stylelint-disable */
|
||||
@include ltr() {
|
||||
padding-right: var(--ion-safe-area-right);
|
||||
padding-left: calc(var(--ion-safe-area-left, 0px) + #{$list-header-md-padding-start});
|
||||
}
|
||||
|
||||
@include rtl() {
|
||||
padding-right: calc(var(--ion-safe-area-right, 0px) + #{$list-header-md-padding-start});
|
||||
padding-left: var(--ion-safe-area-left);
|
||||
}
|
||||
/* stylelint-enable */
|
||||
|
||||
min-height: $list-header-md-min-height;
|
||||
|
||||
|
@ -12,3 +12,37 @@ configs().forEach(({ title, screenshot, config }) => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* This behavior needs to be tested in both modes and directions to
|
||||
* make sure the safe area padding is applied only to that side
|
||||
* regardless of direction
|
||||
*/
|
||||
configs().forEach(({ title, screenshot, config }) => {
|
||||
test.describe(title('list-header: basic'), () => {
|
||||
test.describe('safe area', () => {
|
||||
test('should have padding added by the safe area', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<style>
|
||||
:root {
|
||||
--ion-safe-area-left: 40px;
|
||||
--ion-safe-area-right: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<ion-list-header>
|
||||
<ion-label>List Header</ion-label>
|
||||
<ion-button>Button</ion-button>
|
||||
</ion-list-header>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const listHeader = page.locator('ion-list-header');
|
||||
|
||||
await expect(listHeader).toHaveScreenshot(screenshot(`list-header-safe-area`));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 2.0 KiB |