Cookie consent banner disappears when resize the window if the banner placed at top.

Current code is not properly calculating assigning the top css value:

var checkIfPopupIsClosed = debounce(function () {
      var wrapperHeight = $wrapper.outerHeight();
      if (Drupal.settings.eu_cookie_compliance.popup_position) {
        var wrapperTopProperty = parseFloat($wrapper.css('top'));
        if (wrapperTopProperty !== 0) {
          $wrapper.css('top', wrapperHeight * -1);
        }
      }
      else {
        var wrapperBottomProperty = parseFloat($wrapper.css('bottom'));
        if (wrapperBottomProperty !== 0) {
          $wrapper.css('bottom', wrapperHeight * -1);
        }
      }
    }, 50);
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

keen-on.digital created an issue. See original summary.

keen-on.digital’s picture

Patch to fix this issue for Drupal 7 version.

svenryen’s picture

Thanks for the bug report, and for testing the module with a top pinned banner in a real world setting. I'll take a look this weekend. This probably also affect 8.x.

svenryen’s picture

@keen-on.digital, I found a few edge cases and improved the code from your patch a bit. You can find it in the issue fork, as well as in this patch:
https://git.drupalcode.org/project/eu-cookie-compliance/-/merge_requests...

Would you mind checking out the branch from Gitlab or applying the patch and see if that works for you as well?

  • svenryen committed 531cab9 on 7.x-1.x
    Issue #3243770 by svenryen, keen-on.digital: Fixed top banner disappears...
svenryen’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.