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: CSS transform is not applied to popovers correctly in chrome after updating to ionic 5

See original GitHub issue

Bug Report

Ionic version:

[x] 5.x

Current behavior: I am applying (global.scss)

ion-popover {
    div.popover-content {
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
}

to my Popovers to center them as described in https://github.com/ionic-team/ionic/issues/15036. The CSS transform is not applied in chrome. It is applied in firefox tho. Expected behavior: CSS transform should apply consistently in firefox and chrome. Somehow it is not applying in chrome with ionic 5. In ionic 4 it worked.

Steps to reproduce:

  1. Apply transform in the global.scss as shown above.
  2. Open a popover.

Related code: Clone the prepared GitHub repository and have a look yourself with chrome and firefox. https://github.com/timKraeuter/popover-transform-ionic5

Other information: I have opened this thread in the forum: https://forum.ionicframework.com/t/popover-centering-not-working-after-ionic-4-to-5-update/189017

But I think it is a bug as it worked in ionic 4 but not in 5.

Ionic info:

Ionic:

   Ionic CLI                     : 5.4.4 (C:\Users\TimKräuter\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 5.1.0
   @angular-devkit/build-angular : 0.803.26
   @angular-devkit/schematics    : 8.3.26
   @angular/cli                  : 8.3.26
   @ionic/angular-toolkit        : 2.2.0

Utility:

   cordova-res : not installed
   native-run  : 1.0.0

System:

   NodeJS : v10.15.3 (C:\Program Files\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
timKraeutercommented, May 11, 2020

For future readers. My working solution (Angular/Typescript) with a custom animation is:

public async showPopover() {
    const popover: HTMLIonPopoverElement = await this.popoverCtrl.create({
      component: PopoverTransformedComponent,
      backdropDismiss: true,
      enterAnimation: this.enterAnimation,
  });

    await popover.present();
  }

  private enterAnimation = (baseEl: any) => {
    const backdropAnimation = this.animationCtrl.create()
      .addElement(baseEl.querySelector('ion-backdrop'))
      .fromTo('opacity', 0.01, 'var(--backdrop-opacity)')
      .beforeStyles({
        'pointer-events': 'none'
      })
      .afterClearStyles(['pointer-events']);

    // You could alos define the popover-content
    // transform here if you wanted it to
    // still have a scale effect
    const transformAnimation = this.animationCtrl.create()
      .addElement(baseEl.querySelector('.popover-content'))
      .afterStyles( {
        top: '50%',
        left: '50%',
        transform: 'translate(-50%, -50%)'
      });

    const wrapperAnimation = this.animationCtrl.create()
    .addElement(baseEl.querySelector('.popover-wrapper'))
    .addElement(baseEl.querySelector('.popover-viewport'))
    .fromTo('opacity', 0.01, 1);

    return this.animationCtrl.create()
      .addElement(baseEl)
      .easing('cubic-bezier(0.36,0.66,0.04,1)')
      .duration(300)
      .addAnimation([backdropAnimation, wrapperAnimation, transformAnimation]);
  }

Thanks @liamdebeasi !

0reactions
ionitron-bot[bot]commented, Jun 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS transform is not applied to popovers correctly in chrome ...
CSS transform should apply consistently in firefox and chrome. Somehow it is not applying in chrome with ionic 5. In ionic 4 it...
Read more >
Popover centering not working after ionic 4 to 5 update
I have debugged in chrome and it seems like the “transform: translate(-50%, -50%) !important;” part is not considered anymore. It still works on ......
Read more >
ionic Popover content position issue - Stack Overflow
When I click on an input field, the popover appears. But, sometimes the position of content of popover is not correct. Can you...
Read more >
signature=4c44794979d36c3b2c6e1161877175aa,ionic-framework ...
5.3.5 (2020-10-07)Bug Fixesbutton: allow any element type to use the "icon-only" slot (#22168) (c454c84)datetime: do not set ampm when the column doesn't ...
Read more >
Change Autocomplete Styles in WebKit Browsers - CSS-Tricks
We got a nice tip from Lydia Dugger via email with a method for changing the styles that WebKit browsers apply to form...
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