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

Expand admonitions in print css? #869

Closed
akhmerov opened this issue Sep 2, 2018 · 11 comments

Comments

@akhmerov
Copy link

commented Sep 2, 2018

Right now (mkdocs v1.0.3 and mkdocs-material v3.0.0) collapsed admonitions stay collapsed in print preview:

image

While this may be the desired behavior, I wanted to double-check whether this is the intention (I think expanding all of these would make more sense).

@squidfunk

This comment has been minimized.

Copy link
Owner

commented Sep 2, 2018

That's indeed a bug. Will fix it in the next release.

@squidfunk squidfunk added the bug label Sep 3, 2018

@squidfunk

This comment has been minimized.

Copy link
Owner

commented Sep 3, 2018

This is actually trickier than expected as it's not solvable via CSS. My research leads me to believe that we need to fix it in JavaScript (see this StackOverflow question) for which I need some more time. Again, happy to merge a PR.

@squidfunk

This comment has been minimized.

Copy link
Owner

commented Feb 13, 2019

Added a hack in 71fc5d1

@squidfunk

This comment has been minimized.

Copy link
Owner

commented Feb 13, 2019

Released as part of 4.0.1

@squidfunk squidfunk closed this Feb 13, 2019

@bs-jena

This comment has been minimized.

Copy link

commented May 17, 2019

Am I doing something wrong, or doesn't this work any longer? It used to, and we all were happy, but now it doesn't. (MkDocs 1.0.4 + MkDocs Material 4.2.0)

@squidfunk

This comment has been minimized.

Copy link
Owner

commented May 17, 2019

Still works on my machine. Just tested in with Chrome, Firefox and Safari (all macOS) in the official docs. If you're having trouble, please always state your browser, operating system etc.

@bs-jena

This comment has been minimized.

Copy link

commented May 20, 2019

I played around on different OSs (Mojave + Bionic), with different Python, MkDocs/Material versions ... all with the same effect. So I tested different doc sources (extension combinations, theme overrides, etc.) to narrow that down.
Well: Obviously, there is a dependency (which I don't understand) between the search output div in partials/search.html and this functionality to open the details on print. I replaced the built-in search with a Google CSE and removed that bit of code, now I put that back in (which does not do anything, otherwise), and it works. Weird.

@squidfunk

This comment has been minimized.

Copy link
Owner

commented May 20, 2019

@bs-jena could you check if at any stage of your experiments there are errors in the browser console?

@bs-jena

This comment has been minimized.

Copy link

commented May 20, 2019

Removing <div class="md-search-result__meta">{{- lang.t("search.result.placeholder") -}}</div> from search.html prevents the details from being auto-opened and produces this error:

Uncaught TypeError: Cannot read property 'textContent' of undefined
    at new e (application.b260a35d.js:1)
    at Object.initialize (application.b260a35d.js:1)
    at (index):247
e @ application.b260a35d.js:1
initialize @ application.b260a35d.js:1
(anonymous) @ (index):247
@squidfunk

This comment has been minimized.

Copy link
Owner

commented May 20, 2019

I see. Overriding the template, I didn't account for all possibilities of missing elements due to theme customization. For this reason, the script execution is halted and the logic which registers the auto-open handler is never executed. One could restructure the flow in application.js and/or make the whole search logic more resilient. However, an easier way for you is to disable search entirely by removing it from the plugins array in your mkdocs.yml:

plugins:
  # - search
@bs-jena

This comment has been minimized.

Copy link

commented May 20, 2019

Sorry, I am not a developer: "restructure the flow in application.js" would mean to move the Before-print hook and Open details before printing sections in front of the entire search section - and that would do the trick? I suppose I can't do this in my locally installed instance ...
Unfortunately, disabling the search is no option, because we do use the search box in the page header, we just put this CSE code snippet there.
Anyway, thanks for your research!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.