fix(popover): viewport can be scrolled if no content present #29215
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Issue number: resolves #29211
What is the current behavior?
In #28861 I fixed a bug that caused
.popover-viewport
to haveoverflow: 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 anion-content
. The linked change made it so that using popovers withoution-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?
.popover-viewport
element has a child content then.popover-viewport
will not be scrollable..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 settingoverflow: 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?
Other information
Dev build:
7.8.2-dev.11711383079.118d48a5
Testing:
I could not find a great way to automate this test, but let me know if anyone has ideas!