Skip to content

fix(menu): main content is not scrollable while swiping - #26976

Merged
liamdebeasi merged 4 commits into
mainfrom
FW-3752
Mar 17, 2023
Merged

fix(menu): main content is not scrollable while swiping#26976
liamdebeasi merged 4 commits into
mainfrom
FW-3752

Conversation

@liamdebeasi

@liamdebeasi liamdebeasi commented Mar 16, 2023

Copy link
Copy Markdown
Contributor

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
    • Some docs updates need to be made in the ionic-docs repo, in a separate PR. See the contributing guide for details.
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue URL: resolves #21193

The .menu-content-open class prevents users from scrolling the content behind a menu when it is open:

pointer-events: none;

However, it does not account for when users accidentally scroll the content while trying to drag the menu open because it is only added once the animation is complete. As a result, it is possible to scroll the content underneath the menu and have the menu gesture activate. This also causes the menu gesture performance to degrade significantly.

What is the new behavior?

  • The .menu-content-open class is added before the open animation starts, preventing any accidental scrolls.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions github-actions Bot added the package: core @ionic/core package label Mar 16, 2023
@liamdebeasi
liamdebeasi marked this pull request as ready for review March 16, 2023 15:41
@averyrousseau

Copy link
Copy Markdown
Contributor

I'm not able to replicate the issue on the current main (i.e. without the fix); is there a trick to it? I added a bunch of ion-items to the basic menu test so it's scrollable, and while the menu-content-open class is definitely not added until the gesture is finished, the backdrop-no-scroll class is applied to the <body> as soon as the menu starts opening, which also prevents scrolling.

2023-03-16.13-28-18.mp4

@liamdebeasi

Copy link
Copy Markdown
Contributor Author

It's easier to reproduce if you try it on an actual phone with touch capabilities rather than with touch simulation: #21193 (comment)

I've found it easiest to repro on Chrome for Android if you try to swipe the menu open and then scroll in a circular motion like the video in the linked comment is doing.

@averyrousseau averyrousseau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, just saw it. It does take a few tries haha. Looks good on the branch though. 👍

@lincolnthree

Copy link
Copy Markdown

Will test, thanks @liamdebeasi!

@lincolnthree

Copy link
Copy Markdown

Looks good here on V7.

@liamdebeasi
liamdebeasi merged commit 88bd8a4 into main Mar 17, 2023
@liamdebeasi
liamdebeasi deleted the FW-3752 branch March 17, 2023 20:51
github-merge-queue Bot pushed a commit that referenced this pull request Jan 23, 2024
…hen 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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ion-content is still scrollable while ion-menu is opening.

3 participants