mkdocs-material icon indicating copy to clipboard operation
mkdocs-material copied to clipboard

Long abbreviations span large width and wrong position in the table

Open Lexachoc opened this issue 1 year ago • 4 comments

Context

No response

Bug description

When having long abbreviations, the tooltip will span the entire screen (I think it's related to this fix: https://github.com/squidfunk/mkdocs-material/issues/4810#issuecomment-1369065888 ) However, this is not so easy to read when using the desktop browser or a larger screen. image

I would expect that the tooltip width to be shorter (normal width but wrapped), I tried to change the --md-tooltip-width by including:

  • stylesheets/extra.css
:root {
  --md-tooltip-width: 20rem !important;
}

But this doesn't work.

I also noticed that the tooltip is rendered in the wrong position when within a table: image

It is related to #4217

So three expected behaviors:

  1. Tooltips span the entire screen only when the screen size is smaller than the value of --md-tooltip-width.
  2. When screen size larger than the value of --md-tooltip-width, the value of --md-tooltip-width is used as the width of the tooltip div.
  3. If tooltip in tables, the position of the tooltip should be correct and should follow the two behaviors mentioned above.

Chrome: Version 121.0.6167.161 Edge: Version 121.0.2277.112 mkdocs-material version: 9.5.9

Related links

  • https://github.com/squidfunk/mkdocs-material/issues/4810#issuecomment-1369065888
  • https://github.com/squidfunk/mkdocs-material/issues/4217

Reproduction

9.5.9-long-abbreviations-issue.zip

Steps to reproduce

  1. unzip
  2. run mkdocs serve in terminal
  3. go to http://localhost:8000/

Browser

No response

Before submitting

Lexachoc avatar Feb 11 '24 03:02 Lexachoc

Thanks for reporting and for the reproduction. This is already fixed in Insiders, as we swapped out the tooltip implementation to implement footnote tooltips and instant previews. Once we've collected a little more feedback on those features, we'll back port the new business logic which should also fix this problem ☺️

Bildschirm­foto 2024-02-11 um 12 24 33

squidfunk avatar Feb 11 '24 05:02 squidfunk

@squidfunk Thank you for your quick reply! I'm glad that it is already fixed and the new features is wonderful!

Lexachoc avatar Feb 11 '24 07:02 Lexachoc

@Lexachoc The extra css:

:root {
  --md-tooltip-width: 20rem !important;
}

isn't enough because by default it won't break words. I provided a temporary makeshift solution in a discussion here: https://github.com/squidfunk/mkdocs-material/discussions/6757#discussioncomment-8433750

kamilkrzyskow avatar Feb 11 '24 16:02 kamilkrzyskow

@kamilkrzyskow Thank you! I tried your solution and it works great! Also for the tooltip fontsize CSS hint! I also found that the default tooltip fontsize a bit small for me. Now it looks better when I set it to font-size: 0.6rem;

For a better look of the tooltip, I modified the CSS (from: https://github.com/squidfunk/mkdocs-material/discussions/6757#discussioncomment-8433750) to:

.md-tooltip, .md-tooltip--inline {
  max-width: 10rem;
  word-break: break-all;
  white-space: break-spaces;
}

This way there will be no extra spaces on the left and right side if the tooltip is shorter. image image image

Thank you again!

Lexachoc avatar Feb 11 '24 17:02 Lexachoc

Fixed in 599193edfae0d5c879788115075ef7a1eef2e266 – I backported the new tooltip implementation from Insiders in the refactor/tooltip-positioning branch! If you could spare a few minutes and check whether this fixes your issue, we can release it in the next days ☺️ Install with:

pip install git+https://github.com/squidfunk/mkdocs-material.git@refactor/tooltip-positioning

PR: #7045

squidfunk avatar Apr 14 '24 07:04 squidfunk

@squidfunk Thanks for this PR.

image

I can confirm that the issue has been resolved.

Lexachoc avatar Apr 15 '24 12:04 Lexachoc

Thanks! Keeping open until released.

squidfunk avatar Apr 15 '24 13:04 squidfunk

Released as part of 9.5.18.

squidfunk avatar Apr 16 '24 03:04 squidfunk

Hi all,

I updated to 9.5.18 and the following CSS no longer has any affect on my tooltips - what is the new way to specify the font size, colour etc?

.md-tooltip, .md-tooltip--inline {
    max-width: 15rem;
    word-break: normal;
    white-space: break-spaces;
	font-weight: normal;
}

.md-tooltip__inner,
.md-tooltip--inline .md-tooltip__inner {
	max-width: 15rem;
    font-size: 0.7rem;
	color: blue;
	font-weight: normal;

oceanclub1970 avatar Apr 16 '24 20:04 oceanclub1970

@oceanclub1970

simply with

[role=tooltip]>.md-tooltip2__inner {
  font-size: 1rem;
}

will do the trick

Result: image

Lexachoc avatar Apr 16 '24 20:04 Lexachoc

Thanks @Lexachoc for sharing! Improved tooltips are still experimental, which means we might change the implementation as we discover new problems on the way without considering it a breaking change.

Note that .md-tooltip2* is also a class name/scope that is ephemeral – right now we have two co-existing tooltip implementations that will be consolidated once everything is sorted out. We just needed to solve the bugs quickly, which is why I decided to let them co-exist for a short while. I hope for your understanding – adopting customizations like width and font size will be very easy as @Lexachoc pointed out.

squidfunk avatar Apr 17 '24 00:04 squidfunk