question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: The new ion-content > 'div.scroll-content' breaks position:sticky and IntersectionObserver API (such as ion-virtual-scroll)

See original GitHub issue

Bug Report

Ionic version:

4.x [x] 5.x

Current behavior:

Any elements contained in an ion-content element, using position: sticky, will only stay stuck until the bottom of the new .scroll-content div implemented in issue #20185, scrolls off the screen.

Expected behavior:

Sticky elements should not be pushed off the screen as ion-content is scrolled down. This will manifest in other ways as well (not just position-sticky), but it will also affect intersection observers (such as those used on ion-img and ion-virtual-scroll).

Steps to reproduce:

https://stackblitz.com/edit/ionic-v4-angular-tabs-uiajby

  1. Run the sample app and scroll down on Tab1.
  2. The grey header will stick briefly, then unstick when the bottom of the .scroll-content div move up off the screen.

Related code:

<ion-content>
    <ion-card class="welcome-card">
      <ion-card-header>
        <ion-card-subtitle>Get Started</ion-card-subtitle>
        <ion-card-title>Welcome to Ionic</ion-card-title>
      </ion-card-header>
      <ion-card-content>
        <p>Now that your app has been created, you'll want to start building out features and components. Check out some of the resources below for next steps.</p>
      </ion-card-content>
    </ion-card>


    <!-- This element will scroll off the viewport once the bottom of the ion-content .scroll-content div is reached -->
    <ion-list-header class="sticky-header">
      <ion-label class=ion-text-wrap>Resources (Scroll down to stick this element and see viewport issue)</ion-label>
    </ion-list-header>

https://stackblitz.com/edit/ionic-v4-angular-tabs-uiajby

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 100000;
  background-color: grey;
}

Other information:

This is likely fixed by using the CSS min-height: 100% attribute on the .scroll-content div, rather than the height: 100% attribute.

Shadow DOM is great but makes it very difficult to work around issues like this. Not sure what the compromise needs to be, however, as no layout will be perfect.

Ionic info:

Ionic:

   Ionic CLI                     : 5.4.13 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 5.0.0-beta.5
   @angular-devkit/build-angular : 0.900.0-rc.9
   @angular-devkit/schematics    : 9.0.0-rc.9
   @angular/cli                  : 9.0.0-rc.9
   @ionic/angular-toolkit        : 2.1.1

System:

   Android SDK Tools : 26.1.1 (/Users/lincoln/Library/Android/sdk)
   NodeJS            : v12.13.0 (/usr/local/lib/node_modules/node/bin/node)
   npm               : 6.13.6
   OS                : macOS Catalina
   Xcode             : Xcode 11.3.1 Build version 11C504

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
liamdebeasicommented, Jan 22, 2020

Glad to hear it’s working. I’ve fixed the issue via #20258, and the fix will be available in an upcoming release of Ionic Framework.

1reaction
lincolnthreecommented, Jan 22, 2020

@liamdebeasi Looks like that takes care of the issue. Thanks for the quick patch! Confirmed ion-infinite-scroll and position: sticky both work again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ionic 4 problem when adding content before ion-virtual-scroll
When I wrote the question I was not thinking that some div without any CSS will make this issue, but it does.
Read more >
merge release-4.10.0 · 7768ab2307 - Ionic - Wolfhappens Gitea
-62,7 +62,7 @@ A list of the breaking changes introduced to each component in ... we recommend importing it into a global file,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found