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.

[next] Tooltips breaks line on spaces on a container with position: 'absolute'

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

The tooltip with a title of “Test Title” to be shown without line breaks:

Current Behavior

The tooltip adds a line break for every space in the title: image At first I thought it was a length issue, but it doesn’t break when there’s no spaces: image

Steps to Reproduce (for bugs)

https://codesandbox.io/s/2wnv5jw2xj

  1. Container should have position: ‘absolute’
  2. Add an IconButton surrounded by a Tooltip
  3. Set Tooltip’s title to Test Title

Context

I’m making a floating menu with absolute positioning, that moves around the screen to line up with an active component.

Your Environment

Tech Version
Material-UI ^1.0.0-beta.22
React ^15.5.4
browser Chromium Version 63.0.3239.84 (Official Build) Built on Ubuntu , running on Ubuntu 16.04 (64-bit)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
desktpcommented, Jan 7, 2018

Thanks for the workaround! I’ve tried messing with the positioning and widths, but it didn’t occur to me to override the internal classes.

1reaction
gregnbcommented, Jan 1, 2018

@desktp I think issue boils down to the container div that Popper uses to show the Tooltip. Because that container has a certain width the text inside will get squished and you end up with what appears as line breaks. Simple way around this is to just set the tooltip to be 100% width of that container

I forked your codesandbox was able to get it to work by utilizing the classes prop on Tooltip. https://codesandbox.io/s/8yj6ryzjx2

  1. modify styles to provide width 100% for tooltip
const styles = {
  root: {
    textAlign: 'center',
    paddingTop: 200,
    position: 'absolute',
  },
  tooltip: {
    width: '100%'
  }
};
<Tooltip 
  placement="right-end" 
  title="Title with spaces"
  classes={{
    tooltip: this.props.classes.tooltip
  }}
>

material-fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

[next] Tooltips breaks line on spaces on a container ... - GitHub
I'm making a floating menu with absolute positioning, that moves around the screen to line up with an active component. Your Environment. Tech ......
Read more >
CSS Tooltips line break - Stack Overflow
I fixed the issue by taking out the tooltip from the text content element, and wrapped the tooltip and text content width another...
Read more >
Tooltips · Bootstrap v5.0
When triggered from hyperlinks that span multiple lines, tooltips will be centered. Use white-space: nowrap; on your <a> s to avoid this behavior....
Read more >
How to Show, Position, and Style a Tooltip in HTML and CSS?
For the purpose of positioning the tooltip we are using the absolute value of the position property so that it can be placed...
Read more >
Building a simple tooltip component that never goes off screen
The idea is to set the container with position: relative while the dropdown has a position: absolute and we can use a combination...
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