Skip to content

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Mar 25, 2024

Issue number: resolves #29211


What is the current behavior?

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, and we could not think of a reason to not support the same use case for popover.

What is the new behavior?

  • 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 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
  • No

Other information

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!

@liamdebeasi liamdebeasi changed the title Fw 6075 fix(popover): viewport can be scrolled if no content present Mar 25, 2024
@github-actions github-actions bot added the package: core @ionic/core package label Mar 25, 2024
* we should fallback to the old behavior for environments that do not support :has.
* Developers can explicitly enable this behavior by setting overflow: visible
* on .popover-viewport if they know they are not going to use an ion-content.
* TODO FW-XXXX Remove this
Copy link
Contributor Author

@liamdebeasi liamdebeasi Mar 25, 2024

Choose a reason for hiding this comment

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

If the team is on board with this approach, I'll make a tech debt ticket and populate the ticket number here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I vote for this approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also good with this approach 👍

@liamdebeasi liamdebeasi marked this pull request as ready for review March 25, 2024 17:24
@liamdebeasi liamdebeasi requested review from a team and brandyscarney as code owners March 25, 2024 17:24
@thetaPC
Copy link
Contributor

thetaPC commented Mar 26, 2024

As for tests, could we do one of the following:

  • query the styles and check if it has overflow: hidden;
  • use the scrollIntoViewIfNeeded() function on the last element in a long list. If the last element is visible then it worked.
@liamdebeasi liamdebeasi requested a review from thetaPC April 1, 2024 14:40
@liamdebeasi
Copy link
Contributor Author

Good idea! I added a similar test to the PR.

Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

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

LGTM

@liamdebeasi liamdebeasi added this pull request to the merge queue Apr 1, 2024
@liamdebeasi liamdebeasi removed this pull request from the merge queue due to a manual request Apr 1, 2024
@liamdebeasi liamdebeasi enabled auto-merge April 1, 2024 20:19
@liamdebeasi liamdebeasi added this pull request to the merge queue Apr 1, 2024
Merged via the queue into main with commit f08759c Apr 1, 2024
@liamdebeasi liamdebeasi deleted the FW-6075 branch April 1, 2024 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

3 participants