fix(modal): prevent sheet gesture crash with late-bound breakpoints - #31202
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
3 tasks done
HappyKnuckles
pushed a commit
to HappyKnuckles/ionic-framework
that referenced
this pull request
Oct 3, 2026
…onic-team#31202) Issue number: internal --------- ## What is the current behavior? Currently, when an `ion-modal`'s `breakpoints` are set after the component has loaded, `sortedBreakpoints` stays empty. `breakpointsChanged` had no `@Watch`, so it only ran once from the manual call in `componentDidLoad`. `present()` still recalculates `isSheetModal` to `true` from the late-set `breakpoints` (added in ionic-team#30839), so the sheet gesture initializes with an empty breakpoints array and throws `Reduce of empty array with no initial value` on the `breakpoints.reduce(...)` in `sheet.ts` when the sheet is swiped, which breaks swiping entirely. This shows up with framework bindings that land after the web component loads, e.g., an inline `ion-modal` inside an Angular component rendered through a plain `router-outlet` with zoneless change detection. It doesn't reproduce with zone change detection, with `ModalController.create`, or with the modal inside `ion-router-outlet`, since those set `breakpoints` before the modal presents. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> Now `breakpointsChanged` has `@Watch('breakpoints')`, so `breakpoints` set after the component loads update `sortedBreakpoints`. This mirrors how `trigger`/`triggerChanged` already handles late binding (a watch plus a manual call in `componentDidLoad`). The sheet gesture then gets the real breakpoints and swiping works. ## Does this introduce a breaking change? - [ ] Yes - [X] No ## Other information Sheet modal preview: - https://ionic-framework-git-fix-modal-late-breakpoints-ionic1.vercel.app/src/components/modal/test/sheet Note that the preview won't show *this* working, but will show the modal at least isn't broken from this change. Current dev build: ``` 8.8.10-dev.11781019195.14a7eeaf ```
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: internal
What is the current behavior?
Currently, when an
ion-modal'sbreakpointsare set after the component has loaded,sortedBreakpointsstays empty.breakpointsChangedhad no@Watch, so it only ran once from the manual call incomponentDidLoad.present()still recalculatesisSheetModaltotruefrom the late-setbreakpoints(added in #30839), so the sheet gesture initializes with an empty breakpoints array and throwsReduce of empty array with no initial valueon thebreakpoints.reduce(...)insheet.tswhen the sheet is swiped, which breaks swiping entirely.This shows up with framework bindings that land after the web component loads, e.g., an inline
ion-modalinside an Angular component rendered through a plainrouter-outletwith zoneless change detection. It doesn't reproduce with zone change detection, withModalController.create, or with the modal insideion-router-outlet, since those setbreakpointsbefore the modal presents.What is the new behavior?
Now
breakpointsChangedhas@Watch('breakpoints'), sobreakpointsset after the component loads updatesortedBreakpoints. This mirrors howtrigger/triggerChangedalready handles late binding (a watch plus a manual call incomponentDidLoad). The sheet gesture then gets the real breakpoints and swiping works.Does this introduce a breaking change?
Other information
Sheet modal preview:
Note that the preview won't show this working, but will show the modal at least isn't broken from this change.
Current dev build: