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): viewport can be scrolled if no content present #29215

Merged
merged 8 commits into from Apr 1, 2024
Merged

Conversation

liamdebeasi
Copy link
Member

@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
Member Author

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 brandyscarney and a team 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
Member 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 added this pull request to the merge queue Apr 1, 2024
Merged via the queue into main with commit f08759c Apr 1, 2024
46 checks passed
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: popover without ion-content not scrollable
3 participants