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

Position bar in default placement is offset to left, except for admin users #44

Closed
yorkshire-pudding opened this issue Sep 9, 2022 · 10 comments · Fixed by #45
Closed
Labels
bug Something isn't working

Comments

@yorkshire-pudding
Copy link
Contributor

yorkshire-pudding commented Sep 9, 2022

Steps to reproduce

  1. add tocbot to site
  2. Add content with structured headings
  3. Add tocbot block to layout in right sidebar
  4. Compare page while logged in and when logged out - start at top position and scroll so the block goes 'fixed'

Expected results
Vertical position bar runs directly below the left hand side of the first letter of title (e.g. Contents)
Same position for logged in and logged out
When scroll down, then stays in same place

Actual result
For logged out users the bar is offset to left until the block goes 'fixed' position then it goes to the right place
chrome_U68iGubu1i

For logged in users, the bar is in the right place in the default position and when the block goes 'fixed' position
chrome_cLUWuQ5TWw

Attempts to deduce cause

  • My theme? - same in brand new lando site with basis
  • Browser - same in Chrome and Firefox
  • Turn off caching - same
  • Turned off Aggregate CSS and JS - same
  • compare CSS produced - identical in logged out and logged in.
@yorkshire-pudding yorkshire-pudding added the bug Something isn't working label Sep 9, 2022
@olafgrabienski
Copy link
Member

olafgrabienski commented Sep 12, 2022

Thanks for your report – this issue looks like a tricky one, no idea so far why it's happening!

I noticed one interesting thing, though: If you're not logged in to your Backdrop site as administrator and inspect the element .toc-link::before with your browser's dev tools and have a look at the box-sizing visualization, you'll see quite different position numbers for the default and the fixed Tocbot state:

Default:
tocbot-position-a-not-fixed

Fixed:
tocbot-position-b-fixed

These differences aren't visible if you are logged in as admin to the Backdrop site. So, the position behavior seems related to this issue, but why?

@olafgrabienski olafgrabienski changed the title Position bar in default placement is offset to left for anonymous users Position bar in default placement is offset to left, except for admin users Sep 12, 2022
@olafgrabienski
Copy link
Member

If you're not logged in to your Backdrop site as administrator ...

Testing the issue, I noticed that logging in fixes it only for users with the administrator role. If you log in as an editor, the strange position behavior continues. I'm curious if we can boil this down to a particular permission or something else more specific than the role.

@yorkshire-pudding
Copy link
Contributor Author

Thanks for investigating @olafgrabienski - this is curious - I didn't think to test with non-admin user.

@yorkshire-pudding
Copy link
Contributor Author

The permission appears to be "Administer Layouts" 😕 - very confusing

@olafgrabienski
Copy link
Member

olafgrabienski commented Sep 12, 2022

I'm curious if we can boil this down to a particular permission ...

Yep, just noticed this myself. To be more precise, Administer Layouts and Use contextual links. So, I guess the contextual link CSS and/or JavaScript affects the position.

@yorkshire-pudding
Copy link
Contributor Author

I'd added that previously and nothing happened, but guess that's because the permission to do anything wasn't there so no links were being invoked.

@yorkshire-pudding
Copy link
Contributor Author

Looks to be the position: relative; line in contextual-links-region that fixes it.

.contextual-links-region {
    outline: none;
    position: relative;
}

@olafgrabienski
Copy link
Member

Yes ... without the contextual links region the Tocbot block is static, and that makes the difference for the position issue of the elements.

@yorkshire-pudding
Copy link
Contributor Author

Adding

.js-toc-block {
  position: relative;
}

into tocbot-style.css seems to work

yorkshire-pudding added a commit to yorkshire-pudding/tocbot that referenced this issue Sep 12, 2022
olafgrabienski added a commit that referenced this issue Sep 12, 2022
@olafgrabienski
Copy link
Member

@yorkshire-pudding Thanks again, I've merged your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants