Repository navigation
fix(modal): use drag distance for sheet dismissal - #31524
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
thetaPC
left a comment
There was a problem hiding this comment.
Thanks for tracking this down! Fixing progress to use the drag distance is the right call. I left a few line comments, mostly about the early return 0 for sheets with only 0 and 1 breakpoints.
Two other things:
mainhas the same bug since 8.8.0 (#30962), so it ships in 8.8.x and 9.0.x too. Should the progress fix targetmain, with the physics-based part handled whenmainsyncs intonext?- The PR title is 83 characters, and CONTRIBUTING caps commit headers at 50. Maybe
fix(modal): stop sheets dismissing on upward drags?
@thetaPC Thank you for the thorough review! I've applied your suggestions and also created a separate PR to add the progress based fix to target main (#31553). Could you please take another look at this PR as well as the new PR targeting main? |
Issue number: resolves internal --------- <!-- 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. --> Dragging a sheet modal upwards dismisses it, depending on where the user's pointer is relative to the viewport height rather than how far they dragged. It happens when the pointer is in the bottom half of the viewport, so it's most noticeable on smaller sheet modals where the whole sheet sits in that area. Swiping up should scroll the content, or expand the sheet if it isn't at its largest breakpoint yet. Dragging a sheet upwards no longer dismisses it. How open the sheet is now comes from the drag distance over the sheet's own height, so the breakpoint it snaps to and the position it's drawn at come from the same measurement. Sheets with breakpoints in between snap to the nearest one. A quick downward flick still dismisses, because the drag is projected forward by its velocity before snapping to the nearest breakpoint. A small, slow drag snaps the sheet back instead of closing it. Event progress (`ionDragMove`/`ionDragEnd`) is now normalized to 0 at the lowest breakpoint and 1 at the highest, matching the documented contract. Additionally, the Ionic theme's physics-based gesture is refactored to use the fixed progress calculation. Velocity constants are renamed to describe the gesture direction (`FLICK_DOWN_VELOCITY`, `FLICK_UP_VELOCITY`) rather than the outcome. The redundant velocity check in the 40% dismissal rule is removed, so medium-speed downward drags past the threshold now dismiss instead of snapping back. - [ ] 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/docs/CONTRIBUTING.md#footer for more information. --> - [Sheet Modal Test Page](https://ionic-framework-git-rou-13053-fix-modal-sheet-dismissal-ionic1.vercel.app/src/components/modal/test/sheet/) --------- Co-authored-by: ionitron <hi@ionicframework.com>
Issue number: resolves internal
What is the current behavior?
Dragging a sheet modal upwards dismisses it, depending on where the user's pointer is relative to the viewport height rather than how far they dragged. It happens when the pointer is in the bottom half of the viewport, so it's most noticeable on smaller sheet modals where the whole sheet sits in that area. Swiping up should scroll the content, or expand the sheet if it isn't at its largest breakpoint yet.
What is the new behavior?
Dragging a sheet upwards no longer dismisses it. How open the sheet is now comes from the drag distance over the sheet's own height, so the breakpoint it snaps to and the position it's drawn at come from the same measurement. Sheets with breakpoints in between snap to the nearest one.
A quick downward flick still dismisses, because the drag is projected forward by its velocity before snapping to the nearest breakpoint. A small, slow drag snaps the sheet back instead of closing it.
Event progress (
ionDragMove/ionDragEnd) is now normalized to 0 at the lowest breakpoint and 1 at the highest, matching the documented contract.Additionally, the Ionic theme's physics-based gesture is refactored to use the fixed progress calculation. Velocity constants are renamed to describe the gesture direction (
FLICK_DOWN_VELOCITY,FLICK_UP_VELOCITY) rather than the outcome. The redundant velocity check in the 40% dismissal rule is removed, so medium-speed downward drags past the threshold now dismiss instead of snapping back.Does this introduce a breaking change?
Other information