Problem/Motivation
When having the cookie banner appear at the top of the page, but on pages where it should be hidden (eg. Hide on Admin pages) the banner moves to display above the admin toolbar, with the extra padding where the banner would be on body tag. It looks like the cookie banner is trying to hide itself with a minus margin, but becuase the admin toolbar pushes the body tag down with padding the banner ends up displaying over admin toolbar.
I have seen this effect with Gin, Adminimal, Claro and Seven as admin themes.

Steps to reproduce
Enable the Cookie banner and select position as top.
Do not select 'If the banner is at the top, don't scroll the banner with the page.'
Enable at least one of 'Exclude admin pages', 'Don't show the banner for site administrators (including UID 1).' or add an admin path to Exclude paths.
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot 2021-10-12 at 9.34.55 am.png | 155.88 KB | andybroomfield |
Issue fork eu_cookie_compliance-3243001
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:
- 3243001-banner-at-top
changes, plain diff MR !43
Comments
Comment #2
svenryen commentedThanks for the report, we'll take a look. This issue might also affect 7.x.
Comment #4
svenryen commented@andybroomfield, first of all, thanks a lot for placing the banner at the top and reporting this bug. We need users with all configurations, and the top position hasn't been as thoroughly tested as it should.
I made an issue branch. It would be great if you can try it out and report back how it performs for you. Here's also a patch file if you prefer to use that: https://git.drupalcode.org/project/eu-cookie-compliance/-/merge_requests...
Comment #5
andybroomfieldThanks for the quick fix @svenryen
This does now hide the banner on the admin side

When using Gin, there is an extra gap that appears, which might be something Gin is adding.

This fix seems to have introduced a strange bug on the front end where the banner now floats over the toolbar instead of in the padded space in the theme.

When checking out the main branch, this has the expected position below the toolbar.

Comment #6
svenryen commentedComment #7
svenryen commentedI'll make one more attempt, but making the banner consistently render below the toolbar has proven troublesome. If I can't make it render below the toolbar after a few hours, I'm afraid we'll have to use the behavior in this branch (which displays it at the very top with no parts of the banner obscured for all themes I've tried).
It's been troublesome to make the banner appear correctly at the top, and I believe the current behavior is consistent across themes. I understand there's some annoyance when admins see the banner, but you can exclude the banner from being shown for their role. Alternately the banner can be placed at the bottom if admins that use the toolbar need to see the banner and consent to cookies being stored.
When using Claro, Gin, Seven, Olivero and Bartik, I consistently see the banner at the very top of the page, and I'm unable to reproduce the behavior seen in your screenshots.
Comment #8
svenryen commented@andybroomfield , I know it's been a while, but I've been busy.
Would you be able to test the patch again, I've done a small rewrite and hope that I caught all edge cases and that the banner now successfully renders below the toolbar on all themes. I tested on Seven, Gin and Claro and it's looking promising so far.
https://git.drupalcode.org/project/eu-cookie-compliance/-/merge_requests...
Comment #12
svenryen commentedSomething went wrong with the issue branch, so I cherry-picked the relevant commits.
Comment #14
andybroomfieldHi @svenryen
Thanks, sorry for late response.
I've tested this and the fix included in 1.20-beta1 fixes the issue of the cookie banner overlapping the toolbar.
The only minor detail is the z-index of 99999 still pushes it over the banner when sliding in / out or scrolling if the banner is not fixed in place.
I think setting it to 499 should solve that for the out the box css, and I should be able to apply my own custom css to resolve that.