Skip to content

Commit d47b7e7

Browse files
fix(tab-bar): apply safe area to proper side regardless of direction (#28372)
Issue number: Internal --------- ## What is the current behavior? The safe area padding (both left and right) swap sides when the app's direction changes from LTR to RTL. The `--ion-safe-area-left` should always apply to the left side of the device and the `--ion-safe-area-right` should always apply to the right side of the device. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Updates the tab bar stylesheet to always set `padding-left` and `padding-right` - Adds an e2e test for the basic directory which adds screenshots in both modes/directions for: - the default tab bar - a tab bar with safe area left applied - a tab bar with safe area right applied ## Does this introduce a breaking change? - [ ] Yes - [x] No --------- Co-authored-by: ionitron <[email protected]>
1 parent f99d530 commit d47b7e7

14 files changed

+50
-3
lines changed

core/src/components/tab-bar/tab-bar.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@
66
* @prop --border: Border of the tab bar
77
* @prop --color: Color of the tab bar
88
*/
9-
10-
@include padding-horizontal(var(--ion-safe-area-left), var(--ion-safe-area-right));
11-
129
display: flex;
1310

1411
align-items: center;
1512
justify-content: center;
1613

1714
width: auto;
1815

16+
/* stylelint-disable */
17+
padding-right: var(--ion-safe-area-right);
1918
padding-bottom: var(--ion-safe-area-bottom, 0);
19+
padding-left: var(--ion-safe-area-left);
20+
/* stylelint-enable */
2021

2122
border-top: var(--border);
2223

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { expect } from '@playwright/test';
2+
import { configs, test } from '@utils/test/playwright';
3+
4+
/**
5+
* This behavior needs to be tested in both modes and directions to
6+
* make sure the safe area padding is applied only to that side
7+
* regardless of direction
8+
*/
9+
configs().forEach(({ title, screenshot, config }) => {
10+
test.describe(title('tab-bar: basic'), () => {
11+
test.describe('safe area', () => {
12+
test('should have padding added by the safe area', async ({ page }) => {
13+
await page.setContent(
14+
`
15+
<style>
16+
:root {
17+
--ion-safe-area-left: 40px;
18+
--ion-safe-area-right: 20px;
19+
}
20+
</style>
21+
22+
<ion-tab-bar selected-tab="1">
23+
<ion-tab-button tab="1">
24+
<ion-label>Recents</ion-label>
25+
</ion-tab-button>
26+
27+
<ion-tab-button tab="2">
28+
<ion-label>Favorites</ion-label>
29+
<ion-badge>23</ion-badge>
30+
</ion-tab-button>
31+
32+
<ion-tab-button tab="3">
33+
<ion-label>Settings</ion-label>
34+
</ion-tab-button>
35+
</ion-tab-bar>
36+
`,
37+
config
38+
);
39+
40+
const tabBar = page.locator('ion-tab-bar');
41+
42+
await expect(tabBar).toHaveScreenshot(screenshot(`tab-bar-safe-area`));
43+
});
44+
});
45+
});
46+
});
4.01 KB
Loading
4.36 KB
Loading
3.78 KB
Loading
4.03 KB
Loading
4.37 KB
Loading
3.77 KB
Loading
3.06 KB
Loading
3.48 KB
Loading

0 commit comments

Comments
 (0)