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

Horizontal scrollbar on mobile after hiding header when using header.autohide (Linux only) #2934

Closed
5 tasks done
vedranmiletic opened this issue Aug 13, 2021 · 20 comments
Closed
5 tasks done
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@vedranmiletic
Copy link
Contributor

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

I have enabled header.autohide under features. Header gets hidden as expected, but horizontal scrollbar appears after that.

Expected behaviour

Horizontal scrollbar should not appear.

Actual behaviour

Horizontal scrollbar appears.

Steps to reproduce

  1. Enable header.autohide under features.
  2. Open a long page.
  3. Scroll.

Package versions

  • Python: 3.9.2
  • MkDocs: 1.2.2
  • Material: 7.2.4

Configuration

site_name: Group for apps and services on exascale research infrastructure
site_url: https://group.miletic.net/
theme:
  name: material
  features:
    - header.autohide

System information

  • Operating system: Android
  • Browser: Latest Firefox and Chrome

I have successfully reproduced it on Chromium 90.0.4430.212 and Brave 1.28.105 on Linux using latest MkDocs version and minimal config posted above. It doesn't seem to happen in Debian's Firefox 78.13 ESR.

I'm attaching a recording made in Brave responsive view of the bug appearing on the public version of the docs. The public version is compiled using 7.2.3, but the bug happens in 7.2.4 as mentioned above.

@squidfunk squidfunk added the needs investigation Issue must be investigated by the maintainers label Aug 13, 2021
@squidfunk
Copy link
Owner

squidfunk commented Aug 13, 2021

Thanks for reporting. I'm seeing the behavior in your screen capture but I'm not able to reproduce it in Chrome, Safari or Firefox on macOS. I currently don't have Linux or Windows at my disposal. It's weird that this is happening because the only thing that is applied to the header when it hides is the following:

.md-header[data-md-state=hidden] {
    transform: translateY(-100%);
    transition: transform .25s cubic-bezier(.8,0,.6,1), box-shadow .25s;
}

@squidfunk squidfunk added needs reproduction Issue lacks a minimal reproduction .zip file and removed needs investigation Issue must be investigated by the maintainers labels Aug 13, 2021
@vedranmiletic
Copy link
Contributor Author

Using mobile view is essential. Alternatively, can you check on your mobile phone?

@squidfunk
Copy link
Owner

squidfunk commented Aug 13, 2021

I just checked it on my iPhone, and it's working as expected. No scrollbars. Also, I've checked all browsers in mobile view before writing my last comment. Could you take a shot a debugging this, i.e. which element causes this + PR a fix? It should probably be trivial to fix.

@squidfunk
Copy link
Owner

Did you manage to isolate the issue or even attempt a fix?

@tuanpht
Copy link

tuanpht commented Aug 17, 2021

I had also faced this issue, you can check this video I tested with Firefox Responsive Mode on Ubuntu

mkdocs-horizontal-scrollbar-w.mp4

I fixed by adding this custom css:

.md-header[data-md-state="hidden"] {
  overflow: hidden;
}

@squidfunk
Copy link
Owner

Thanks for providing a potential fix! I'd be curious to learn which element is causing the header to overflow. Could you investigate this? It would be better to solve the root cause, because setting overflow: hidden might have unintended consequences.

@squidfunk
Copy link
Owner

Could you try to delete the .md-search element and see whether the error persists without your fix? I suspect this element to be the cause.

@tuanpht
Copy link

tuanpht commented Aug 17, 2021

It would be better to solve the root cause, because setting overflow: hidden might have unintended consequences.

Sorry, I haven't found the root cause yet. This also cause Back to Top button jumping out of main area

mkdocs-scroll-to-top-lagging-w.mp4

@tuanpht
Copy link

tuanpht commented Aug 17, 2021

Could you try to delete the .md-search element and see whether the error persists without your fix? I suspect this element to be the cause.

@squidfunk I've tried this and it works

mkdocs-horizontal-scroll-md-search-w.mp4

@squidfunk
Copy link
Owner

squidfunk commented Aug 17, 2021

Perfect, so that's the cause! It's strange that this only happens on Linux and only when the header is moved out of sight. The least invasive potential fix I can think of (without being able to test) is:

.md-header[data-md-state="hidden"] .md-search {
  overflow: hidden;
}

The idea is to only clip the search element, not the entire header. Some users might add stuff to the header which would suddenly be clipped before moved out of sight. Also, when the search is open, the header is always visible, so both states (header hidden, search visible) are disjoint.

Could you try and apply that? If it works, I can add it to master.

@tuanpht
Copy link

tuanpht commented Aug 17, 2021

Sorry, I tried but it doesn't work.

I found the cause is .md-search__inner, the following css works, I had to add width: 0.

.md-header[data-md-state="hidden"] .md-search__inner {
   overflow: hidden;
   width: 0;
}

But it is not perfect, horizontal scrollbar still appear a moment when I scroll down and then scroll up... This is not good when you scroll up fast on mobile.

mkdocs-horizontal-scrollbar-issue-w.mp4

Let's investigate more.

@squidfunk
Copy link
Owner

But it is not perfect, horizontal scrollbar still appear a moment when I scroll down and then scroll up... This is not good when you scroll up fast on mobile.

And the same happens with the following snippet you posted earlier, correct?

.md-header[data-md-state="hidden"] {
  overflow: hidden;
}

@squidfunk
Copy link
Owner

squidfunk commented Aug 17, 2021

So the problem appears to be .md-search__inner. It's positioned with fixed and with left: 100%, as it is animated to move from the left into the screen when the search is triggered on mobile. My guess is that if you add the following CSS, the problem should vanish:

.md-search__inner {
  left: 0;
  transform: none;
}

However, this introduces other problems. Essentially, we must only trigger this rule for the entire time the header is hidden (+ start and end animation). I haven't managed to find a way to do this reliably, yet. Any help with somebody who can debug this is appreciated.

@squidfunk squidfunk added bug Issue reports a bug and removed needs reproduction Issue lacks a minimal reproduction .zip file labels Aug 17, 2021
@squidfunk squidfunk changed the title Horizontall scrollbar appears on mobile after hiding header when using header.autohide Horizontal scrollbar on mobile after hiding header when using header.autohide (Linux only) Aug 22, 2021
@ErliSoares
Copy link
Contributor

I have the same problem, it happens on Windows OS with Chrome and Chrome on android.

mkdocs.yml

site_name: Demo Error

copyright: Copyright © Example

theme:
  name: material
  features:
    - header.autohide

docs/index.md

---
title: Page Error
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum finibus consectetur turpis.

## Lorem Ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum finibus consectetur turpis, id ultrices enim lacinia id. Pellentesque lacinia blandit condimentum. Donec at elementum est. Duis commodo sit amet lorem a pellentesque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

Morbi semper lectus leo, vel vulputate mi ultricies nec. Suspendisse potenti. Phasellus congue enim sed lectus faucibus, ac mattis ipsum efficitur. Donec sem erat, semper nec elit quis, convallis mattis nunc. Donec pharetra nunc non nisi rutrum mattis. Ut vitae urna arcu. Aliquam elit sapien, fringilla vitae ante id, condimentum gravida risus. Praesent efficitur lobortis massa condimentum suscipit.

Vivamus lacinia magna non varius consequat. Nullam scelerisque mi et augue imperdiet, sit amet vulputate arcu iaculis. Nam eu nisl a arcu sollicitudin vehicula.

Suspendisse vel pretium mi. Vivamus in feugiat arcu, eu lobortis quam. Aliquam at nisi pellentesque, efficitur elit lobortis, egestas neque.

Suspendisse quis metus purus. Nullam commodo condimentum dolor, a blandit orci. Aenean aliquet eget libero at dignissim. Maecenas ultrices aliquam sem, vitae eleifend velit molestie sit amet. Vivamus rhoncus velit eget turpis vulputate feugiat.

@ErliSoares
Copy link
Contributor

If you place any image in html with header.autohide enabled, the page width gets bigger.

Projeto.sem.titulo.mp4
---
title: Page Error
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum finibus consectetur turpis.

## Lorem Ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum finibus consectetur turpis, id ultrices enim lacinia id. Pellentesque lacinia blandit condimentum. Donec at elementum est. Duis commodo sit amet lorem a pellentesque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

Morbi semper lectus leo, vel vulputate mi ultricies nec. Suspendisse potenti. Phasellus congue enim sed lectus faucibus, ac mattis ipsum efficitur. Donec sem erat, semper nec elit quis, convallis mattis nunc. Donec pharetra nunc non nisi rutrum mattis. Ut vitae urna arcu. Aliquam elit sapien, fringilla vitae ante id, condimentum gravida risus. Praesent efficitur lobortis massa condimentum suscipit.

Vivamus lacinia magna non varius consequat. Nullam scelerisque mi et augue imperdiet, sit amet vulputate arcu iaculis. Nam eu nisl a arcu sollicitudin vehicula.

Suspendisse vel pretium mi. Vivamus in feugiat arcu, eu lobortis quam. Aliquam at nisi pellentesque, efficitur elit lobortis, egestas neque.

Suspendisse quis metus purus. Nullam commodo condimentum dolor, a blandit orci. Aenean aliquet eget libero at dignissim. Maecenas ultrices aliquam sem, vitae eleifend velit molestie sit amet. Vivamus rhoncus velit eget turpis vulputate feugiat.

<img src="any_image">

Morbi semper lectus leo, vel vulputate mi ultricies nec. Suspendisse potenti. Phasellus congue enim sed lectus faucibus, ac mattis ipsum efficitur. Donec sem erat, semper nec elit quis, convallis mattis nunc. Donec pharetra nunc non nisi rutrum mattis. Ut vitae urna arcu. Aliquam elit sapien, fringilla vitae ante id, condimentum gravida risus. Praesent efficitur lobortis massa condimentum suscipit.


Morbi semper lectus leo, vel vulputate mi ultricies nec. Suspendisse potenti. Phasellus congue enim sed lectus faucibus, ac mattis ipsum efficitur. Donec sem erat, semper nec elit quis, convallis mattis nunc. Donec pharetra nunc non nisi rutrum mattis. Ut vitae urna arcu. Aliquam elit sapien, fringilla vitae ante id, condimentum gravida risus. Praesent efficitur lobortis massa condimentum suscipit.

@squidfunk
Copy link
Owner

Possible fix in d678678. I think I've fixed the issue for when the header is hidden. There may still be some edge cases, but the scrollbar shouldn't be visible anymore. I hope this does not introduce other issues. In case it does, we'll revert the fix again.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Sep 19, 2021
@squidfunk
Copy link
Owner

Released as part of 7.2.7.

@tuanpht
Copy link

tuanpht commented Sep 22, 2021

Thank you :)

I confirmed it works on my phone Chrome for Android

@vedranmiletic
Copy link
Contributor Author

Works for me as well, tested extensively yesterday on group.miletic.net using mobile Firefox and mobile Chrome, both on Android. Thanks!

@squidfunk
Copy link
Owner

Perfect, glad we could sort it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

4 participants