canonical / canonical/react-components

Tooltip width hard to change

Open
#978 4 comments 0 reactions 0 assignees View on GitHub
P3 Triaged Triaged: new architecture
Dominant language
TypeScript
Stars
151
Forks
74
Avg merge
1d 2h
Merged PRs (30d)
11

Description

### Issue
There are instances where we would like to limit the `max-width` of `Tooltip` without setting a fixed width for it (e.g. the generated content is dynamic and can be long). Unfortunately, something simple like `max-width: 20rem; white-space: pre-wrap;` won't work, as, in the case the width of the `Tooltip` is 0, the text would just appear one word per line (as seen in the attached screenshot).

### Possible fix
We could utilize something similar to [`breakLines` from `maas-ui`](https://github.com/canonical/maas-ui/blob/main/src/app/utils/breakLines.ts) and break long text into lines of specific length, which would allow us to indirectly set-up `max-width` of `Tooltip`.

### Screenshot
![Screenshot from 2023-09-15 23-14-07](https://github.com/canonical/react-components/assets/108150922/8f75ceb2-820a-42cc-ae2c-dc35c6553e6b)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.