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

bug: native status bar padding breaking ion-header #21483

Closed
2 of 4 tasks
Tialko opened this issue Jun 5, 2020 · 3 comments
Closed
2 of 4 tasks

bug: native status bar padding breaking ion-header #21483

Tialko opened this issue Jun 5, 2020 · 3 comments
Labels

Comments

@Tialko
Copy link

Tialko commented Jun 5, 2020

Bug Report

Capacitor Version

npx cap doctor output:

@capacitor/electron not installed
@capacitor/cli 2.1.0
@capacitor/core 2.1.0
@capacitor/android 2.1.0
@capacitor/ios 2.1.0

Affected Platform(s)

  • Android
  • iOS
  • Electron
  • Web

Current Behavior

In the app I am currently developing the status bar is overlapping the app container/viewport.

I manage to resolve this by adding:

padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left),

but this created me another problem in IOS. My ion-header now have and extra padding-top.
It seems like ion-toggle inside ion-headers are inherit some root padding-top behavior.

I manage to create a workaround by forcing the padding-top to 0 in ion-toolbar, but it feels like that this is not the expected behavior as in Android there has no problems.

I just want my app to not overlap the status bar.

How can I achieve this behavior with Capacitor and the Status Bar Plugin?

Sample Code or Sample Application Repo

scss file
:root { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

index.html
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />

somepage.html

<ion-header>
    <ion-toolbar>

        <ion-buttons slot="start">
            <ion-back-button></ion-back-button>
        </ion-buttons>
        <ion-title>{{ PageTitle | translate }}</ion-title>

    </ion-toolbar>
</ion-header>
<ion-content>
...
</ion-content>

Behavior

bug

issuenativebar

Workaround

ion-header {
   ...

    ion-toolbar {
        // Fix the padding created by env(safe-area-inset-top)
        padding-top: 0px !important;
    }
   ...

}

expected

Other Technical Details

npm --version output: 6.13.4

node --version output: 12.16.1

pod --version output (iOS issues only): 1.8.4

@jcesarmobile
Copy link
Member

ionic is supposed to handle that for you, that's probably why you have problems after adding the padding, it messes with ionic components that already take care of safe areas.

moving the issue to ionic repo so it can be properly triaged, but I think you shouldn't be adding that padding

@mhartington mhartington transferred this issue from ionic-team/capacitor Jun 10, 2020
@ionitron-bot ionitron-bot bot added the triage label Jun 10, 2020
@liamdebeasi
Copy link
Contributor

Thanks for the issue. I am going to close this as this is not a bug in Ionic Framework. Ionic Framework handles the safe area padding for you, but if you want to customize the safe area padding you can modify our safe area CSS variables.

Example:

:root {
    --ion-safe-area-top: 20px;
    --ion-safe-area-bottom: 20px;
    --ion-safe-area-right: 20px;
    --ion-safe-area-left: 20px;
  }

These CSS Variables are initially set in https://github.com/ionic-team/ionic/blob/master/core/src/css/core.scss#L133-L156. You could use some combination of the CSS Variables and the env values to get the behavior you desire.

@ionitron-bot
Copy link

ionitron-bot bot commented Jul 10, 2020

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Jul 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants