Skip to content

Commit 7449fb4

Browse files
sean-perkinsIonitronliamdebeasi
authored
fix(action-sheet): iOS dismiss animation respects safe area (#28915)
Issue number: resolves #28541 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> On iOS when dismissing the `ion-action-sheet`, the animation does not account for the safe area of the device. This results in the action sheet not completely animating off the visible viewport on a device with safe area enabled. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - The `ion-action-sheet` will animate consistently off the viewport when dismissing, including the safe area. To better support custom animations not needing to account for the safe area, the safe area has been added to the padding of the action sheet container. This results in the height increasing based on the bottom safe area and animating correctly when translating between [`100%` and `0%`](https://github.com/ionic-team/ionic-framework/blob/9d57758e3ec1095c6eb951d2640b95084b711bbc/core/src/components/action-sheet/animations/ios.enter.ts#L23). |Before|After| |---|---| |<video src="https://github.com/ionic-team/ionic-framework/assets/13732623/d9475a54-f1b9-4283-ae1a-86e2b71a9d9e"></video>|<video src="https://github.com/ionic-team/ionic-framework/assets/13732623/d051b4d9-4f45-4a51-b522-510f8cddef74"></video>| In the recorded examples the bottom safe area is exaggerated to show the dismiss animation differences. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> To test this PR, I would recommend adding the following styles to the action sheet basic test: ```html <style> ion-action-sheet { --ion-safe-area-bottom: 100px; } </style> ``` You can then open dev-tools and slow the animation speed to 10%: ![CleanShot 2024-01-29 at 19 49 32@2x](https://github.com/ionic-team/ionic-framework/assets/13732623/535fa663-213c-4a09-b94a-db334e4d3d29) - Open and dismiss the action sheet tied to the "Basic" button. - Verify that the action sheet animates completely off the view when dismissed. - Open the and dismiss the action sheet tied to the "Custom CSS Class" button. This implementation customizes the `--height` of the action sheet. - Verify that the action sheet animates completely off the view when dismissed. --------- Co-authored-by: ionitron <[email protected]> Co-authored-by: Liam DeBeasi <[email protected]>
1 parent 5777ce2 commit 7449fb4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,24 @@
2626
// ---------------------------------------------------
2727

2828
.action-sheet-wrapper {
29-
@include margin(var(--ion-safe-area-top, 0), auto, var(--ion-safe-area-bottom, 0), auto);
29+
@include margin(var(--ion-safe-area-top, 0), auto, null, auto);
30+
/**
31+
* Bottom safe area is applied as padding so that it impacts the bounding box.
32+
* When the action sheet is shown/hidden, this element is transformed by translating
33+
* 100% of its height. This translation needs to include the bottom safe area
34+
* otherwise part of the action sheet will still be visible at the end of
35+
* the show transition.
36+
*
37+
* If this code is changed, reviewers should verify that the action
38+
* sheet still translates out of the viewport completely when the bottom
39+
* safe area is a positive value.
40+
*/
41+
@include padding(null, null, var(--ion-safe-area-bottom, 0), null);
42+
43+
// Using content-box to increase the height of the action sheet
44+
// wrapper by the bottom padding (safe area) to animate the
45+
// action sheet completely off the screen when safe area is set.
46+
box-sizing: content-box;
3047
}
3148

3249
// iOS Action Sheet Container

0 commit comments

Comments
 (0)