Skip to content

Translucent ion-header/ion-toolbar measures --ion-safe-area-top exactly once and never re-measures, breaking on platforms where the real value arrives asynchronously (Android edge-to-edge) #31337

Closed

Description

@schallm

Title: Translucent ion-header/ion-toolbar measures --ion-safe-area-top exactly once and never re-measures, breaking on platforms where the real value arrives asynchronously (Android edge-to-edge)

Prerequisites

Ionic Info

Ionic:
   Ionic CLI                       : (not relevant, using @ionic/angular directly)
   @ionic/angular                  : 8.8.16

Capacitor:
   @capacitor/android              : 8.5.0
   @capacitor/core                 : 8.5.0

Platform: Android (Capacitor), targetSdk 35+/36, edge-to-edge (mandatory on this OS version, no opt-out).

Current Behavior

A translucent <ion-header [translucent]="true"> with a matching <ion-content [fullscreen]="true"> measures the app's --ion-safe-area-top CSS custom property exactly once, at component initialization, and caches whatever value it read at that moment. If the real value only becomes known after that initial measurement — which is unavoidable on Android, where the true status-bar inset is only available asynchronously via a native WindowInsets callback dispatched after Activity.onCreate() — the header permanently renders as if the safe area were 0, even once the CSS variable is later updated to the correct value.

Confirmed via a runtime probe logging both the CSS variable and the toolbar's measured position over time:

t0:      --ion-safe-area-top=0px   toolbarTop=n/a
t100ms:  --ion-safe-area-top=24px  toolbarTop=n/a
t500ms:  --ion-safe-area-top=24px  toolbarTop=0
t1500ms: --ion-safe-area-top=24px  toolbarTop=0
t3000ms: --ion-safe-area-top=24px  toolbarTop=0

The CSS variable is correctly updated to 24px by ~100ms and stays correct — but the toolbar's own layout never reflects it, at any point afterward, including 3 seconds later.

Expected Behavior

The header should react to changes in --ion-safe-area-top (and the other --ion-safe-area-* variables) after initialization — e.g. via a MutationObserver on the CSS custom property, or by re-measuring on window resize/orientation events, rather than caching a one-time JS measurement. This would make translucent headers correctly handle any platform/runtime where the true safe-area value isn't synchronously available at component init — which, going forward, includes Android, now that edge-to-edge is OS-mandatory there (Android 15+) and Capacitor's WebView doesn't populate env(safe-area-inset-*) for the general status bar (only for display cutouts — a separate, narrower case that iOS's WKWebView doesn't distinguish this way).

Steps to Reproduce

  1. Capacitor Android app, targetSdk 35+.
  2. Native side: apply the real status-bar inset to the WebView late (e.g. via a WindowInsets listener registered on the Activity's decor view, since — separately — listening directly on the WebView itself receives all-zero insets on Capacitor; see companion issue filed against capacitor-android), pushing the correct value into --ion-safe-area-top via document.documentElement.style.setProperty(...) once it's known.
  3. Observe: even though the CSS variable is now correct, any [translucent]="true" ion-header present at that point continues to render as if it were 0 — content still appears under the status bar.
  4. A plain (non-translucent) header, or a completely fresh page navigated to after the value is corrected, is unaffected — only headers that existed at/before the mismeasurement stay wrong, consistent with a cached one-time read rather than a live calculation.

Code Reproduction Link

Happy to put together a minimal Capacitor+Ionic Angular repro if useful — the behavior above was observed in a real app, not yet isolated into a standalone reproduction repo.

Ionic Framework Info

Framework: Angular (@ionic/angular 8.8.16)
Capacitor: 8.5.0
Platform: Android, targetSdk 36

Activity

  1. ionitron-bot commented on Aug 7, 2026

    @ionitron-bot

    Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

    Please reproduce this issue in an Ionic starter application and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

    If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

    For a guide on how to create a good reproduction, see our Contributing Guide.

  2. ShaneK commented on Aug 7, 2026

    @ShaneK
    Member

    Hey, thanks for the issue report! I'd love to take a look at fixing this issue for you, but to make this issue a lot smoother and remove some of the guess work it really helps to have a reproduction. Please let me know when you've added one and I'll check it out!

  3. schallm commented on Aug 8, 2026

    @schallm
    ContributorAuthor

    Minimal reproduction: https://gist.github.com/schallm/e54c2b8f96a385e024de60382f8a0e1a

    Live preview (no download needed): https://gistpreview.github.io/?e54c2b8f96a385e024de60382f8a0e1a/index.html

    It's a single self-contained HTML file loading @ionic/core from a CDN (no framework, no build step) with a translucent ion-header + fullscreen ion-content. --ion-safe-area-top starts at 0px (matching the real device's initial state before the native inset callback fires), then ~800ms after load it's updated to 24px via document.documentElement.style.setProperty(...) — simulating the async arrival that happens for real on Android edge-to-edge.

    A live probe logs --ion-safe-area-top and ion-toolbar's getBoundingClientRect().top to the page and console every second or so. Console output:

    t=730ms   --ion-safe-area-top=0px   toolbar.getBoundingClientRect().top=0
    t=1853ms  --ion-safe-area-top=24px  toolbar.getBoundingClientRect().top=0
    t=2852ms  --ion-safe-area-top=24px  toolbar.getBoundingClientRect().top=0
    t=3852ms  --ion-safe-area-top=24px  toolbar.getBoundingClientRect().top=0
    t=5853ms  --ion-safe-area-top=24px  toolbar.getBoundingClientRect().top=0
    

    The CSS variable updates and holds correctly at 24px, but the toolbar's measured position never changes from 0 at any point afterward — visually the header stays pinned to the very top of the viewport instead of dropping below the (simulated) status bar. There's a "Re-run" button on the page to trigger the update again manually if you want to poke at it further.

    This isolates the bug down to ion-header/ion-toolbar itself — no Capacitor, no native code, no Android involved. Let me know if a different reproduction shape would be more useful.

  4. added
    type: buga confirmed bug report
    and removed on Aug 10, 2026
  5. added theissue type on Aug 10, 2026
  6. ShaneK commented on Aug 10, 2026

    @ShaneK
    Member

    Thank you so much for your report and reproduction!

    I have a PR up to address this issue. If you want to try it out before we merge and release it, you can use this dev build:

    8.8.18-dev.11786399582.1d58c37d
    
  7. ShaneK commented on Aug 12, 2026

    @ShaneK
    Member

    Thanks for highlighting this issue, this is fixed now as part of v8.8.18!

  8. added a commit that references this issue on Aug 12, 2026
    bc4fce2
  9. schallm commented on Aug 15, 2026

    @schallm
    ContributorAuthor

    Confirmed this works. Thanks for resolving the issue!

  10. ionitron-bot commented on Sep 14, 2026

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  11. locked and limited conversation to collaborators on Sep 14, 2026
  12. added a commit that references this issue on Oct 3, 2026
    c7dc32f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: buga confirmed bug report

    Type

    Fields

    Stage

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions