Skip to content

Commit 9603a4d

Browse files
authored
fix(menu): improve reliability of main content not being scrollable when menu opens (#28829)
Issue number: resolves #28399 --------- <!-- 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. --> As part of #26976 I fixed an issue where `pointer-events: none` was not applied until after the menu open gesture finishes. This resolved a bug where scrolling was latching after the menu gesture starts. However, I did not account for the edge case where scrolling latches _before_ `pointer-events: none` is applied in the DOM. Since scrolling has already latched then `pointer-events: none` does not change the scrolling behavior. This can happen if a user swipes up and to the right from the left edge of the screen. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - `overflow-y: hidden` is now applied to the scrollable content which will interrupt any scrolling when the menu is open. ## 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. --> Testing: This bug fixes a timing issue where scrolling latches on the main content as the menu tries to open. As a result, I am unable to write reliable automated tests for this. Reviewers should perform the following test on iOS and Android physical devices: 1. Open `src/components/menu/test/basic`. 2. Add enough elements to the main page content such that it scrolls (I added a list with items). 3. On each device, attempt to scroll the main content while also opening the menu on the starting edge of the screen. Scrolling on the main content should not happen if the menu opens. Dev build: `7.6.5-dev.11705341148.1a550d3b`
1 parent 10c38d0 commit 9603a4d

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

core/src/css/core.scss

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,36 @@ ion-card-header.ion-color .ion-inherit-color {
250250
cursor: pointer;
251251
touch-action: manipulation;
252252

253-
// the containing element itself should be clickable but
254-
// everything inside of it should not clickable when menu is open
253+
/**
254+
* The containing element itself should be clickable but
255+
* everything inside of it should not clickable when menu is open
256+
*
257+
* Setting pointer-events after scrolling has already started
258+
* will not cancel scrolling which is why we also set
259+
* overflow-y below.
260+
*/
255261
pointer-events: none;
262+
263+
/**
264+
* This accounts for scenarios where the main content itself
265+
* is scrollable.
266+
*/
267+
overflow-y: hidden;
268+
}
269+
270+
/**
271+
* Setting overflow cancels any in-progress scrolling
272+
* when the menu opens. This prevents users from accidentally
273+
* scrolling the main content while also dragging the menu open.
274+
* The code below accounts for both ion-content and then custom
275+
* scroll containers within ion-content (such as virtual scroll)
276+
*/
277+
.menu-content-open ion-content {
278+
--overflow: hidden;
279+
}
280+
281+
.menu-content-open .ion-content-scroll-host {
282+
overflow: hidden;
256283
}
257284

258285
.ios .menu-content-reveal {

0 commit comments

Comments
 (0)