question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature suggestion: Show title on mouseover on overflowing nav items

See original GitHub issue

Contribution guidelines

I want to suggest an idea and checked that …

  • … to my best knowledge, my idea wouldn’t break something for other users
  • … the documentation does not mention anything about my idea
  • … there are no open or closed issues that are related to my idea

Description

If a nav item has a very long title, the title is truncated with ellipsis, which is good to prevent the nav from scrolling horizontally. (This may be Insiders only, not sure.)

However, it would be nice if users could see the full title on mouseover, like this:

2022-03-31_15-58-52

Basically, I can see two solutions for this:

  1. Add a title attribute to all nav items. This can easily be done by modifying the nav-item partial. However, this creates a lot of redundancy, especially on large doc projects with huge navs.
  2. Add a title attribute to overflowing nav items only. This can be done using JS. See code below. (Yes, it’s jQuery! Heresy! But to get an idea.)
// Add title to overflowing nav links
$(".md-ellipsis").each(function () {
    if (this.offsetWidth < this.scrollWidth) {
        $(this).attr("title", $(this).text().trim());
    }
});

Use Cases

See description.

Screenshots / Mockups

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
squidfunkcommented, May 8, 2022

Insiders 4.15.0 was just released and comes with improved support for tooltips 🎉 This release also includes the behavior mentioned above, automatically adding a tooltip to overflowing navigation titles.

1reaction
squidfunkcommented, Apr 6, 2022

Thanks for suggesting! As a general note, I’m working on better hover behavior for elements with titles (including abbreviations specifically), and fixing this issue will be a part of it. It might take some time, but the logic is the same, so it wouldn’t make sense to solve this specifically.

In the mean time, the following script should mitigate the issue (adapted from your code example to remove jQuery):

document$.subscribe(() => {
  document.querySelectorAll(".md-ellipsis").forEach(el => {
    if (this.offsetWidth < this.scrollWidth) {
      el.setAttribute("title", el.innerText)
    }
  })
})

Note that will only work in Insiders, since it makes use of the refactoring of the navigation structure to support icons.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Showing the description on mouseover - Stack Overflow
1 Answer 1 · Yeah it worked perfectly. · Is it really necessary to use bootstrap to show the title in tool tip?...
Read more >
Our Faves: Top 12 Navbar Hover Effects and Effects on Click
In this post, we have collected some of the most creative navbar demos ... get a menu that stacks items into a dropdown...
Read more >
Dropdown | Webflow University
Select a dropdown link; Open Style panel > Selector field and open the dropdown; Choose Hover from the States menu. Once selected, a...
Read more >
Tooltips - Bootstrap
Documentation and examples for adding custom Bootstrap tooltips with CSS and JavaScript using CSS3 for animations and data-attributes for local title storage.
Read more >
title - HTML: HyperText Markup Language - MDN Web Docs
Other tags such as <p> surround and provide information about document text and may include other tags as sub-elements. Browsers do not display...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found