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

Add truncation for content beyond 2 lines and show tooltip with original value if content was truncated #3123

Merged
merged 13 commits into from
Oct 18, 2023

Conversation

teodosii
Copy link
Member

@teodosii teodosii commented Oct 5, 2023

What this PR does

  • Removed MAX_LINE_LENGTH which was used to truncate Integrations Name
  • Added new component TextEllipsisTooltip that determines if its content was truncated, and if so, it will show a tooltip with the original value. Integrations Name and Alert Group Name fields inside tables have been changed so that after filling in 2 lines, the content gets truncated and a tooltip is shown on hover.

Before
image
After
image

As you can see this results in more space being taken for the integrations name (but no more than what it should take), and the end result is always truncated after 2 lines. Same applies to the Integrations

Before
image
After
image

The Don't delete integration wasn't even showing 100% of its full width in the before screen, but it shows in the after because now there's no more limit on the characters.

@teodosii teodosii requested a review from a team October 5, 2023 09:27
@teodosii teodosii added the pr:no public docs Added to a PR that does not require public documentation updates label Oct 5, 2023
@teodosii teodosii changed the title Increased max characters for integration name in table view Add truncation for content beyond 2 lines and show tooltip with original value if content was truncated Oct 16, 2023
@teodosii teodosii force-pushed the rares/increase-integration-max-characters branch from 52b6ce3 to 14687d8 Compare October 16, 2023 11:27
text,
tooltipTitle,
tooltipContent,
placement,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe placement = 'bottom-start' to use 'bottom-start' as default

const elContentRef = useRef<HTMLDivElement>(null);

useEffect(() => {
setEllipsis();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's called only onMount, but textContent and children can be changed later

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In current use cases the content cannot change, the only issue is on resizing as that will determine truncation, but that's sorted out by onMouseHover.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it's better to add [children] to useEffect deps right now?

}, []);

const elContent = (
<div className={cx(className)} ref={elContentRef} onMouseOver={setEllipsis}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, we'll display tooltip (if element is too long) onMouseOver, but what about calling setEllipsis on onMouseOut ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tooltip is not displayed on onMouseHover, it just updates the state to know it's a truncated element - from there is just normal rendering (which will include tooltip as well)

Copy link
Member Author

@teodosii teodosii Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we need to call it on mouseleave?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, just looks a bit weird to update the state on onMouseHover, in theory mouse hovering shouldn't affect this state...

Copy link
Member Author

@teodosii teodosii Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO that's a good spot for checking if anything changed - just for this case. It's like a trigger to show the tooltip, instead we just update the state which will show the tooltip... I don't like setting it on resize, maybe there are some other actions triggering truncation which I'm not aware of right now, onMouseOver catches every case.

<HorizontalGroup>
<TextEllipsisTooltip placement="top" content={user.username}>
<Text type="secondary" className={cx('overflow-child')}>
<Avatar size="small" src={user.avatar} />{' '}
Copy link
Member Author

@teodosii teodosii Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed from medium to small so that it's consistent with other places (see incident's users, schedule current user at the top or the teams icon)

@teodosii teodosii added this pull request to the merge queue Oct 18, 2023
Merged via the queue into dev with commit f23ae99 Oct 18, 2023
@teodosii teodosii deleted the rares/increase-integration-max-characters branch October 18, 2023 11:47
brojd pushed a commit that referenced this pull request Sep 18, 2024
…nal value if content was truncated (#3123)

# What this PR does

- Removed `MAX_LINE_LENGTH` which was used to truncate Integrations Name
- Added new component `TextEllipsisTooltip` that determines if its
content was truncated, and if so, it will show a tooltip with the
original value. Integrations Name and Alert Group Name fields inside
tables have been changed so that after filling in 2 lines, the content
gets truncated and a tooltip is shown on hover.

Before

![image](https://github.com/grafana/oncall/assets/40542072/1bdd29f3-5804-45f1-85b1-69657d26c73f)
After

![image](https://github.com/grafana/oncall/assets/40542072/1a68c3ed-5884-431f-8a6f-f8ea1185987c)

As you can see this results in more space being taken for the
integrations name (but no more than what it should take), and the end
result is always truncated after 2 lines. Same applies to the
Integrations

Before

![image](https://github.com/grafana/oncall/assets/40542072/802e9a4f-89b5-461d-9c04-15d7117cdb8b)
After

![image](https://github.com/grafana/oncall/assets/40542072/a0674469-bdcc-4051-9783-9ffc81b8ba31)

The `Don't delete` integration wasn't even showing 100% of its full
width in the before screen, but it shows in the after because now
there's no more limit on the characters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants