mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
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 |  |  | | **Safe Area** |  |  | ### Material Design | | Before (`main`) | After (`FW-4715`) | | -------------------| ----------------| ------------------| | **No** Safe Area |  |  | | **Safe Area** |  |  | --------- Co-authored-by: ionitron <hi@ionicframework.com>
This commit is contained in:
@ -128,8 +128,8 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
/* Fallback for browsers that do not support dvh */
|
/* Fallback for browsers that do not support dvh */
|
||||||
max-height: 100vh;
|
max-height: calc(100vh - (var(--ion-safe-area-top, 0) + var(--ion-safe-area-bottom, 0)));
|
||||||
max-height: 100dvh;
|
max-height: calc(100dvh - (var(--ion-safe-area-top, 0) + var(--ion-safe-area-bottom, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
.action-sheet-group {
|
.action-sheet-group {
|
||||||
|
|||||||
@ -100,3 +100,69 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ config, title }) =>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This behavior needs to be tested in both modes but does not vary
|
||||||
|
* across directions due to the component only applying safe area
|
||||||
|
* to the top and bottom
|
||||||
|
*/
|
||||||
|
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
|
||||||
|
test.describe(title('action-sheet: basic'), () => {
|
||||||
|
test.describe('safe area', () => {
|
||||||
|
test('should have padding added by the safe area', async ({ page }, testInfo) => {
|
||||||
|
testInfo.annotations.push({
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/ionic-team/ionic-framework/issues/27777',
|
||||||
|
});
|
||||||
|
await page.setContent(
|
||||||
|
`
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--ion-safe-area-top: 60px;
|
||||||
|
--ion-safe-area-bottom: 40px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<ion-action-sheet></ion-action-sheet>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const actionSheet = document.querySelector('ion-action-sheet');
|
||||||
|
actionSheet.header = 'Header';
|
||||||
|
actionSheet.subHeader = 'Sub Header';
|
||||||
|
actionSheet.buttons = [
|
||||||
|
'Add Reaction',
|
||||||
|
'Copy Text',
|
||||||
|
'Share Text',
|
||||||
|
'Copy Link to Message',
|
||||||
|
'Remind Me',
|
||||||
|
'Pin File',
|
||||||
|
'Star File',
|
||||||
|
'Mark Unread',
|
||||||
|
'Mark Read',
|
||||||
|
'Edit Title',
|
||||||
|
'Erase Title',
|
||||||
|
'Save Image',
|
||||||
|
'Copy Image',
|
||||||
|
'Erase Image',
|
||||||
|
'Delete File',
|
||||||
|
{
|
||||||
|
text: 'Cancel',
|
||||||
|
role: 'cancel'
|
||||||
|
},
|
||||||
|
];
|
||||||
|
</script>
|
||||||
|
`,
|
||||||
|
config
|
||||||
|
);
|
||||||
|
|
||||||
|
const ionActionSheetDidPresent = await page.spyOnEvent('ionActionSheetDidPresent');
|
||||||
|
const actionSheet = page.locator('ion-action-sheet');
|
||||||
|
|
||||||
|
await actionSheet.evaluate((el: HTMLIonActionSheetElement) => el.present());
|
||||||
|
await ionActionSheetDidPresent.next();
|
||||||
|
|
||||||
|
await expect(actionSheet).toHaveScreenshot(screenshot(`action-sheet-safe-area`));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Reference in New Issue
Block a user