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

[#55581] popover for user information on hover #17255

Merged
merged 79 commits into from
Dec 4, 2024

Conversation

EinLama
Copy link
Contributor

@EinLama EinLama commented Nov 22, 2024

Ticket

https://community.openproject.org/wp/55581

What are you trying to accomplish?

User hover cards when hovering over the avatar. I tried also showing the hover card when hovering over the name, but it felt wonky and overly verbose. EDIT: as discussed in the frontend daily, the wonkyness is no longer present with an increased delay before showing a hover card. So showing it for names is an option now. We decided that I will create an open point for this topic so that we can decide how to proceed with this. In case we want to add this, I would supply another PR for that, as it will be much smaller in scope.

Please take extra care when reviewing this. I have tried to check every place where a user principal is rendered, but might have missed some due to the sheer number of them.

Screenshots

image

user.popover.information.mov

Note: the video is not completely accurate. The arrow pointing downwards towards the avatar has been removed because it's not possible to position it reliably.

What approach did you choose and why?

Reused the HoverCard component from work packages and made some adjustments.

Some changes made to the trigger service (Typescript) also affect the work packages. This includes a longer delay before a hover card appears, as well as a slightly longer delay before it closes. Bugs happening when you quickly over multiple different hover cards have been fixed.

The AvatarComponent as well as the op-principal-component now support an option for enabling hover cards. By default, the popover is enabled. I had to disable the popover in some places where it caused hard-to-fix bugs, such as: it is not possible to render another spot modal within an existing spot modal.

These places include:

  • the global search result dropdown
  • the time tracking modal
  • the work package share modal

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@EinLama EinLama force-pushed the feature/55581-popover-for-user-information-on-hover branch from 1f5454c to 4653b53 Compare November 22, 2024 13:55
Copy link
Contributor

@HDinger HDinger left a comment

Choose a reason for hiding this comment

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

Hi @EinLama

as discussed, the amount of cards feels rather annoying. I'd like the challenge the requirement that the card should really be shown all the time. Alternatively, the delay must be larger. But that has to be discussed with the product team.

Until then, here are the first findings from clicking through:

  • Hovering a placeholder user leads to an error
  • As a non-admin user, there is an error as well due to a missing permission
  • Opening the share modal on a WP creates a black overlay
  • When the LogTime modal on a WP is opened, and the user dropdown is opened: Hovering the avatar, will close the logTime modal
  • The emailAdress is supposed to smaller (12px)
  • When having a very long name, it overflows the card without truncation or wrapping:
Bildschirmfoto 2024-11-22 um 14 11 40
  • When the hovercard is opened at the very bottom of the page, it closes immideatly
Bildschirmaufnahme.2024-11-22.um.14.55.49.mov

For the record, there are some places where the card is not shown yet. But as said above, I'd wait until the decision of the product team

  • Team planner module
  • Admin/user table
  • Project overview / project attribute of type user
  • Project activity page
  • Users page (/users/:id)
  • My Page / News widget
  • Multi-User custom field

app/components/users/hover_card_component.html.erb Outdated Show resolved Hide resolved
@EinLama EinLama force-pushed the feature/55581-popover-for-user-information-on-hover branch from f3869f7 to 95183a7 Compare November 22, 2024 14:25
Copy link
Contributor

@HDinger HDinger left a comment

Choose a reason for hiding this comment

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

It feels like you could save a lot of code by turning the default for the hoverCards to true. Is there a reason it is set to false?

app/components/users/avatar_component.rb Outdated Show resolved Hide resolved
app/components/users/hover_card_component.html.erb Outdated Show resolved Hide resolved
app/components/users/hover_card_component.html.erb Outdated Show resolved Hide resolved
# or
# "Member of group1, group2 and 3 more"
# The latter string is cut off since the complete list of group names would exceed the allowed `max_length`.
def group_membership_summary(max_length = 40)
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the value 40 coming from?

Copy link
Contributor Author

@EinLama EinLama Nov 25, 2024

Choose a reason for hiding this comment

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

A true magic number 🔮🧙🏻‍♂️ found by, uh... guessing and trying it out! 🪄

Seemed sensible when used with the English translation and should look okay with most other languages. The caveat is that only the group names are considered when deciding where to shorten the list. To make it perfect, we'd have to load the translation first, factor it's length into the calculation and THEN decide where to cut off the group list. I figured the value 40 is good enough in most cases and strikes a balance between pleasant looks and code complexity :)

app/components/users/hover_card_component.sass Outdated Show resolved Hide resolved
@@ -48,7 +48,7 @@ export class UserDisplayField extends DisplayField {
element,
this.attribute,
{ hide: false, link: false },
{ hide: false, size: 'medium' },
{ hide: false, size: 'medium', hoverCard: { url: this.attribute.url } },
Copy link
Contributor

Choose a reason for hiding this comment

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

ESLint is somehow complaining correctly here.this.attribute can be anything, so we do not know for sure whether a url is defined. Ideally this case would at least be catched before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were other issues with this class, unrelated to this PR. I have made an attempt at fixing them. The compiler is happy, so far is the runtime. Will observe if this causes problems somewhere in the application.

app/components/users/hover_card_component.sass Outdated Show resolved Hide resolved
@EinLama EinLama force-pushed the feature/55581-popover-for-user-information-on-hover branch 4 times, most recently from 709ca64 to eba7ab8 Compare November 26, 2024 14:42
@EinLama
Copy link
Contributor Author

EinLama commented Nov 26, 2024

Thank you, @HDinger. I have fixed most of the issues and findings. I found another place that triggers erratic behavior:

  • global search closes when hovering over an avatar (e.g. work package authors)

@EinLama EinLama force-pushed the feature/55581-popover-for-user-information-on-hover branch 4 times, most recently from 00addee to 6ce763e Compare November 29, 2024 08:09
It is closer to what we want to achieve.
This is only a draft since the links are still missing.
But it gives a good first impression of what's to come.
We might have to patch a bigger possible size here later,
the default size is currently the biggest and it looks a
bit lost in the hover card.
Previously, it was attached to the wrapper, which led to weird behavior.
With the new approach, it looks more natural while fitting the design
better.

Sneaked in some improvements such as using the hover card path helper.
This was a hard one to debug. When you hover over an avatar as soon as
the page loads, you will hover over the fallback first. Within the
timeout, the actual avatar image loads and replaces the fallback. After
that, the timeout of the hover trigger runs out and displays the hover
cards, but does no longer have an element to position relative to. So,
we check for the existence of the hovered element before showing a hover
card to fix this.
@EinLama EinLama force-pushed the feature/55581-popover-for-user-information-on-hover branch from e6aca92 to 8a1f7b9 Compare November 29, 2024 14:20
EinLama and others added 3 commits November 29, 2024 16:00
If you quickly move from one hover target to the next, we know reset the
hover card component into the correct state so that you can open the
next hover card. Just keep hovering.
@EinLama EinLama marked this pull request as ready for review December 2, 2024 09:25
gap: 1rem
overflow: hidden

.op-user-hover-card--info
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.op-user-hover-card--info
&--info

this could be just &--info. This ensures that you're using the BEM style

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very nice, thanks! The previous class definitions were very cumbersome. Much better like this.

Copy link
Member

@oliverguenther oliverguenther left a comment

Choose a reason for hiding this comment

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

Behavior-wise, LGTM. I have some minor remarks

@EinLama EinLama merged commit cc72da4 into dev Dec 4, 2024
14 of 15 checks passed
@EinLama EinLama deleted the feature/55581-popover-for-user-information-on-hover branch December 4, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants