Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(popover): content inside of popover scrolls correctly #28861

Merged
merged 4 commits into from
Jan 23, 2024
Merged

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Jan 19, 2024

Issue number: resolves #28455


What is the current behavior?

The main ion-content inside of a popover is not scrollable. Instead, the .popover-viewport container is scrolled because certain styles no longer applied once we moved popover to the Shadow DOM. This bug impacted the linked issue because it meant that the infinite scroll inside of the content never fires (since the content never scrolls).

What is the new behavior?

  • The .popover-viewport rule now targets slotted content with the.popover-viewport class. This class is added to the root node that is slotted. This enables us to target the user's content in the light dom.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev build: 7.6.6-dev.11705696534.177666f8

@github-actions github-actions bot added the package: core @ionic/core package label Jan 19, 2024
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We previously changed the box shadow, but this screenshot was not updated due to our diff threshold.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This screenshot was actually captured incorrectly originally. There is a footer in the test template, but due to .popover-viewport not applying the ion-content height was so large that the footer was pushed outside the viewport.

I decided not to add another screenshot because this test already captures the effects of the proposed changes and would fail if the changes were reverted in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Focus is moved to the first item when it's opened, so it looks like this screenshot is correct. They should have been captured sooner, but the diff threshold prevented them from being updated.

@liamdebeasi liamdebeasi marked this pull request as ready for review January 19, 2024 21:58
@liamdebeasi liamdebeasi requested a review from a team as a code owner January 19, 2024 21:58
@liamdebeasi liamdebeasi requested review from thetaPC and averyjohnston and removed request for a team January 19, 2024 21:58
@liamdebeasi
Copy link
Contributor Author

Adding Amanda for review too because she worked on some popover scrolling issues in #24294

@liamdebeasi liamdebeasi added this pull request to the merge queue Jan 23, 2024
Merged via the queue into main with commit 10c38d0 Jan 23, 2024
46 checks passed
@liamdebeasi liamdebeasi deleted the FW-5536 branch January 23, 2024 14:40
github-merge-queue bot pushed a commit that referenced this pull request Feb 5, 2024
Issue number: resolves #28963

---------

<!-- 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. -->

In #28861 I fixed an
issue that caused the wrong content inside of a popover to be
scrollable. This CSS should have been applied, but it broke back when
popover was converted to the Shadow DOM. Fixing this issue revealed a
misconfiguration with the select-popover that caused the select-popover
to no longer be scrollable.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Content inside of `ion-select-popover` can now be scrolled

Note that I am considering this a bug fix instead of a regression. While
scrolling used to work in select-popover, it only worked by chance. The
`.popover-viewport` styles should have always applied to the
select-popover, thus requiring the use of `overflow-y: auto` in
select-popover.

## 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. -->

Dev build: `7.7.1-dev.11706893059.1bef4b38`
github-merge-queue bot pushed a commit that referenced this pull request Apr 1, 2024
Issue number: resolves #29211

---------

<!-- 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. -->

In #28861 I fixed a
bug that caused `.popover-viewport` to have `overflow: hidden`. In
reality, this code should have always applied but due to an incorrect
selector it never did.

As it turns out in
#29211, some
developers were relying on the broken behavior to build their
applications. In particular, developers were using `ion-popover` without
an `ion-content`. The linked change made it so that using popovers
without `ion-content` were not scrollable.

After talking with @mapsandapps we think it makes sense to officially
support this behavior. We support using [modals without
`ion-content`](https://ionicframework.com/docs/api/modal#custom-dialogs),
and we could not think of a reason to not support the same use case for
popover.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- If the `.popover-viewport` element has a child content then
`.popover-viewport `will not be scrollable.
- If the `.popover-viewport` element does not have a child content then
`.popover-viewport` will be scrollable.

I implemented this behavior using progressive enhancement via `:has`.
The [`:has` pseudo-class](https://caniuse.com/?search=%3Ahas) has
cross-browser support. Ionic v7 supports some versions of browsers that
do not have `:has` support. As a result, we fall back to the existing
behavior in this environment. Developers are able to get this behavior
on older browsers by explicitly setting `overflow: auto` on
`.popover-viewport`.

Fortunately, we will be dropping support for several of the older
browsers versions in Ionic v8, so the need to do the manual opt-in
should be less frequent as time goes on.

## 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. -->

Dev build: `7.8.2-dev.11711383079.118d48a5`

Testing:

1. Open https://codepen.io/liamdebeasi/pen/JjVJrZQ?editors=1100 (this
has a dev build installed)
2. Click each button to open a popover.
3. Verify that each popover can be scrolled.

I could not find a great way to automate this test, but let me know if
anyone has ideas!
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-infinite-scroll ionInfinite event does not fire in ion-popovers
3 participants