Skip to content

Commit 900267e

Browse files
fix(action-sheet): adjust height for safe area with scrollable options (#28504)
Issue number: fixes #27777 --------- ## What is the current behavior? When safe area (top/bottom) is applied to an action sheet with scrollable options and a cancel button, the cancel button is pushed off the screen and cannot be reached. ## What is the new behavior? Properly adjust the height of the action sheet container to account for the top and bottom safe area. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information The below screenshots use the following CSS when safe area is added so it is expected that the action sheet will adjust the top and bottom: ```css :root { --ion-safe-area-top: 60px; --ion-safe-area-bottom: 40px; } ``` ### iOS | | Before (`main`) | After (`FW-4715`) | | -------------------| ----------------| ------------------| | **No** Safe Area | ![ios-main-no-safe-area](https://github.com/ionic-team/ionic-framework/assets/6577830/2bbb8c09-6e35-4f88-983c-019cef1b9f44) | ![ios-branch-no-safe-area](https://github.com/ionic-team/ionic-framework/assets/6577830/55d899d3-945e-4d1e-983f-5d9b0a3ad6cc) | | **Safe Area** | ![ios-main-safe-area](https://github.com/ionic-team/ionic-framework/assets/6577830/7b7ea64c-4432-4160-aadb-8be333549bc6) | ![ios-branch-safe-area](https://github.com/ionic-team/ionic-framework/assets/6577830/02143b3a-ca40-4294-b77c-3bb7867da0b9) | ### Material Design | | Before (`main`) | After (`FW-4715`) | | -------------------| ----------------| ------------------| | **No** Safe Area | ![md-main-no-safe-area](https://github.com/ionic-team/ionic-framework/assets/6577830/a448bd22-6d79-4f2c-a0ec-654c6679732f) | ![md-branch-no-safe-area](https://github.com/ionic-team/ionic-framework/assets/6577830/ef8244c4-b8e8-434b-bd06-1d6981396574) | | **Safe Area** | ![md-main-safe-area](https://github.com/ionic-team/ionic-framework/assets/6577830/80e00ce6-eb34-4d87-9546-a49da373fb6b) | ![md-branch-safe-area](https://github.com/ionic-team/ionic-framework/assets/6577830/d8b86141-a65c-4026-b895-8d167ebc6258) | --------- Co-authored-by: ionitron <[email protected]>
1 parent 73b8bfd commit 900267e

8 files changed

+68
-2
lines changed

core/src/components/action-sheet/action-sheet.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@
128128
height: 100%;
129129

130130
/* Fallback for browsers that do not support dvh */
131-
max-height: 100vh;
132-
max-height: 100dvh;
131+
max-height: calc(100vh - (var(--ion-safe-area-top, 0) + var(--ion-safe-area-bottom, 0)));
132+
max-height: calc(100dvh - (var(--ion-safe-area-top, 0) + var(--ion-safe-area-bottom, 0)));
133133
}
134134

135135
.action-sheet-group {

core/src/components/action-sheet/test/basic/action-sheet.e2e.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,69 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ config, title }) =>
100100
});
101101
});
102102
});
103+
104+
/**
105+
* This behavior needs to be tested in both modes but does not vary
106+
* across directions due to the component only applying safe area
107+
* to the top and bottom
108+
*/
109+
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
110+
test.describe(title('action-sheet: basic'), () => {
111+
test.describe('safe area', () => {
112+
test('should have padding added by the safe area', async ({ page }, testInfo) => {
113+
testInfo.annotations.push({
114+
type: 'issue',
115+
description: 'https://github.com/ionic-team/ionic-framework/issues/27777',
116+
});
117+
await page.setContent(
118+
`
119+
<style>
120+
:root {
121+
--ion-safe-area-top: 60px;
122+
--ion-safe-area-bottom: 40px;
123+
}
124+
</style>
125+
126+
<ion-action-sheet></ion-action-sheet>
127+
128+
<script>
129+
const actionSheet = document.querySelector('ion-action-sheet');
130+
actionSheet.header = 'Header';
131+
actionSheet.subHeader = 'Sub Header';
132+
actionSheet.buttons = [
133+
'Add Reaction',
134+
'Copy Text',
135+
'Share Text',
136+
'Copy Link to Message',
137+
'Remind Me',
138+
'Pin File',
139+
'Star File',
140+
'Mark Unread',
141+
'Mark Read',
142+
'Edit Title',
143+
'Erase Title',
144+
'Save Image',
145+
'Copy Image',
146+
'Erase Image',
147+
'Delete File',
148+
{
149+
text: 'Cancel',
150+
role: 'cancel'
151+
},
152+
];
153+
</script>
154+
`,
155+
config
156+
);
157+
158+
const ionActionSheetDidPresent = await page.spyOnEvent('ionActionSheetDidPresent');
159+
const actionSheet = page.locator('ion-action-sheet');
160+
161+
await actionSheet.evaluate((el: HTMLIonActionSheetElement) => el.present());
162+
await ionActionSheetDidPresent.next();
163+
164+
await expect(actionSheet).toHaveScreenshot(screenshot(`action-sheet-safe-area`));
165+
});
166+
});
167+
});
168+
});
25 KB
Loading
32.4 KB
Loading
20 KB
Loading
21.2 KB
Loading
24.8 KB
Loading
15.1 KB
Loading

0 commit comments

Comments
 (0)