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

fix(ui): add a tooltip for commonly truncated fields in the events pane #5062

Merged
merged 2 commits into from Feb 17, 2021

Conversation

dcherman
Copy link
Member

It's not uncommon for the involved object and/or message to be longer
than can be displayed in the events pane, and finding out what the full
string is has often involved going into the inspector to look at the contents
of the element.

Adding a tooltip on these will help mitigate that a bit.

Signed-off-by: Daniel Herman dherman@factset.com

@dcherman dcherman force-pushed the fix/events-panel-usability branch 4 times, most recently from c6b199d to c70a05c Compare February 10, 2021 00:16
@dcherman
Copy link
Member Author

Alternatively, we could also just always add tooltips regardless of whether or not the text is truncated.

@alexec
Copy link
Contributor

alexec commented Feb 10, 2021

I think it would be fine to mouse over and get a pop-up, I think @simster7 added something similar recently

It's not uncommon for the involved object and/or message to be longer
than can be displayed in the events pane, and finding out what the full
string is has often involved going into the inspector to look at the contents
of the element.

Adding a tooltip on these will help mitigate that a bit.

Signed-off-by: Daniel Herman <dherman@factset.com>
@dcherman
Copy link
Member Author

All the time or conditionally? If we want it all the time, I'll swap it to that

@simster7 simster7 self-assigned this Feb 12, 2021
Copy link
Member

@simster7 simster7 left a comment

Choose a reason for hiding this comment

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

I'm sorry, but I'm having a hard time understanding how this PR works. Would you mind answering my questions and adding some screenshots showing the proposed behavior?

cancel();

timer = window.setTimeout(() => {
fn(...args);
Copy link
Member

Choose a reason for hiding this comment

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

calculateTooltips doesn't take parameters?

Copy link
Member Author

Choose a reason for hiding this comment

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

calculateTooltips itself doesn't, but this is a general purpose debounce function similar to what you might find in lodash and/or underscore - it's very useful for deferring work until some frequently occurring event is no longer occuring (in this case, window resize)

https://lodash.com/docs/#debounce

This function supports functions with any arity

const debouncedFn = (...args: Parameters<T>) => {
cancel();

timer = window.setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this timer needed?

Copy link
Member Author

@dcherman dcherman Feb 16, 2021

Choose a reason for hiding this comment

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

See the comment discussing what debounce does (I can add comments to the code as well) - essentially the function that's passed in will not be invoked until the debounced function has not been invoked for N milliseconds

if (col.scrollWidth > col.clientWidth) {
col.title = col.textContent;
} else {
col.title = '';
Copy link
Member

Choose a reason for hiding this comment

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

Should this be ... instead? Or something to indicate we're cutting off text?

Copy link
Member Author

Choose a reason for hiding this comment

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

title is just the tooltip that will show up when you hover over the element with your mouse. The browser itself takes care of truncating with ... when necessary. Setting this to empty basically just disables the tooltip when the full text is visible in your window

const [debouncedCalculateTooltips, cleanup] = debounce(calculateTooltips, 1000);

window.addEventListener('resize', debouncedCalculateTooltips);
calculateTooltips();
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this is called twice? One in debounce and one here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct - this is immediately called in order to set up tooltips based on your current window size, then we call it in a debounced event handler on window resize to recalculate whether or not the tooltips need to be displayed. We debounce it in order to avoid layout thrashing since we access properties like clientWidth and scrollWidth in the function.

@dcherman
Copy link
Member Author

Will add some screenshots / GIFS later today

@dcherman
Copy link
Member Author

Here's a quick GIF demoing the transition from no tooltip, to having a tooltip, to not having one again.

Screen Recording 2021-02-16 at 11 15 27 PM (2)

Copy link
Member

@simster7 simster7 left a comment

Choose a reason for hiding this comment

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

Excellent. Thanks for the explanations @dcherman, the GIF really helped as I had misunderstood the target of this PR :)

@simster7 simster7 merged commit 4aa9847 into argoproj:master Feb 17, 2021
@dcherman dcherman deleted the fix/events-panel-usability branch February 17, 2021 17:49
@simster7 simster7 mentioned this pull request Feb 23, 2021
34 tasks
@simster7 simster7 mentioned this pull request Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants