Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions core/src/components/fab/fab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,29 @@
}

:host(.fab-horizontal-start) {
@include position-horizontal(
calc(#{$fab-content-margin} + var(--ion-safe-area-left, 0px)), null
);
/* stylelint-disable */
@include ltr() {
left: calc(#{$fab-content-margin} + var(--ion-safe-area-left, 0px));
}

@include rtl() {
right: calc(#{$fab-content-margin} + var(--ion-safe-area-right, 0px));
left: unset;
}
/* stylelint-enable */
}

:host(.fab-horizontal-end) {
@include position-horizontal(
null, calc(#{$fab-content-margin} + var(--ion-safe-area-right, 0px))
);
/* stylelint-disable */
@include ltr() {
right: calc(#{$fab-content-margin} + var(--ion-safe-area-right, 0px));
}

@include rtl() {
left: calc(#{$fab-content-margin} + var(--ion-safe-area-left, 0px));
right: unset;
}
/* stylelint-enable */
}


Expand Down
72 changes: 72 additions & 0 deletions core/src/components/fab/test/safe-area/fab.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';

configs({ modes: ['md'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('fab: safe area'), () => {
test('should ignore document direction in safe area positioning for start-positioned fab', async ({ page }) => {
await page.setContent(
`
<style>
:root {
--ion-safe-area-left: 40px;
--ion-safe-area-right: 20px;
}
</style>

<ion-content>
<ion-fab vertical="center" horizontal="start">
<ion-fab-button>
<ion-icon name="add"></ion-icon>
</ion-fab-button>
</ion-fab>
</ion-content>
`,
config
);

/**
* We need to capture the entire page to check the fab's position,
* but we don't need much extra white space.
*/
await page.setViewportSize({
width: 200,
height: 200,
});

await expect(page).toHaveScreenshot(screenshot('fab-safe-area-horizontal-start'));
});

test('should ignore document direction in safe area positioning for end-positioned fab', async ({ page }) => {
await page.setContent(
`
<style>
:root {
--ion-safe-area-left: 40px;
--ion-safe-area-right: 20px;
}
</style>

<ion-content>
<ion-fab vertical="center" horizontal="end">
<ion-fab-button>
<ion-icon name="add"></ion-icon>
</ion-fab-button>
</ion-fab>
</ion-content>
`,
config
);

/**
* We need to capture the entire page to check the fab's position,
* but we don't need much extra white space.
*/
await page.setViewportSize({
width: 200,
height: 200,
});

await expect(page).toHaveScreenshot(screenshot('fab-safe-area-horizontal-end'));
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.