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

Feature/59925 show user popover on the name #17692

Merged
merged 31 commits into from
Feb 4, 2025

Conversation

EinLama
Copy link
Contributor

@EinLama EinLama commented Jan 22, 2025

Ticket

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

What are you trying to accomplish?

Enable the hover card not only on avatars, but also when hovering on names.

  • patch AvatarComponent so that names rendered there will display a hover card.
  • search application for usernames that show up outside of the AvatarComponent
    • linked names in WP journal
    • within auto completers
    • linked names in WP description and comments
    • news
    • wiki
    • admin: users
    • project: members

Notable technical exceptions where the hover card will not render due to technical limitations of our spot modal usage:

  • work package share dialog
  • global search
  • global invitation modal

I am currently working on removing these limitations in a follow-up PR, but wanted to make the current state available for review.

Notable other exceptions where the required effort to patch in hover cards was not worth it in my opinion:

  • the news block on the my-page: it uses a very different way of constructing links. I skipped it since the necessary increase in complexity is not worth it for a single widget.
  • some username entries in WP journals that are not links, but plain text. This happens for example when the activity describes someone setting a new assignee on a work package. The new assignee will not be a link to a user, it will just be the username instead. Again skipped due to complexity vs. gain.

Screenshots

hover_card_on_name.mov

What approach did you choose and why?

I applied the same logic to usernames as I did on the avatars. For some user names (e.g. within auto completers), there was no easy way to inject the necessary parameters into the data attributes of the user name span, so I instead introduced a new CSS class: .op-hover-card--data-on-sibling-principal
If a hover card is triggered, but the source element has this class, the hover card data is sourced from sibling elements if possible.

To cover most other links, I extended ObjectLinking#link_to_user to add hover card info to the link.

Fixed some timing and consistency bugs while on it, too.

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/59925-show-user-popover-on-the-name branch 6 times, most recently from 84926fc to cf1c93e Compare January 29, 2025 07:25
@EinLama EinLama marked this pull request as ready for review January 30, 2025 09:03
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

I don't quite get the necessity for the sibling logic. Maybe we can shortly talk about that. Other than that, I found some issues while testing it:

  • I managed quite often to get to a state where either the name or the avatar does not trigger a hoverCard any more
    Jan-31-2025 09-07-10

  • There seems to an issue with the helper, but I could not quite get my finger on it. The WP info line shortly shows the author as a link before it switches to a text. That does not happen with all users however, I only saw it when the author is my current logged in user. However, even when there is a link shown, there is no hoverCard when hovering it.

Jan-31-2025 09-02-19

  • In the acceptance criteria it is said, that there should be no flicker when switching between name and avatar. The card is however disappearing when I leave the name and reopens when hovering the avatar. Due to the delay it does not feel flickering but I'd neverless like to hear the opinion of the product team on this.
    Jan-31-2025 09-04-03

@EinLama EinLama force-pushed the feature/59925-show-user-popover-on-the-name branch from 967ddd3 to 960f58c Compare February 3, 2025 07:47
@EinLama
Copy link
Contributor Author

EinLama commented Feb 3, 2025

Hey @HDinger,

thank you for your review. You already helped me get rid of the unnecessary bloat fetching data from a sibling element. So that one is done.

I managed quite often to get to a state where either the name or the avatar does not trigger a hoverCard any more

I could reproduce this by "jittering" the mouse cursor over the trigger. The hover card trigger service has a safe-guard that - once shown - will not re-show the same hover card again. This safe-guard was too restrictive and did not consider that you could move the mouse cursor away before the hover card is actually shown. So the trigger service thought it had to safe guard a hover card that wasn't there yet. I moved the safe-guard to the appropriate position and that fixed it. If the cause for your observed behavior was the same, that should be fixed, too.

There seems to an issue with the helper, but I could not quite get my finger on it. The WP info line shortly shows the author as a link before it switches to a text. That does not happen with all users however, I only saw it when the author is my current logged in user. However, even when there is a link shown, there is no hoverCard when hovering it.

I could not reproduce this, nor have I ever seen it 🤔

In the acceptance criteria it is said, that there should be no flicker when switching between name and avatar. The card is however disappearing when I leave the name and reopens when hovering the avatar. Due to the delay it does not feel flickering but I'd neverless like to hear the opinion of the product team on this.

Will discuss later today and report back.

@EinLama
Copy link
Contributor Author

EinLama commented Feb 3, 2025

The hover card disappearing briefly when alternating between username and avatar has been discussed with product and is deemed okay 👍🏻

@EinLama EinLama added the feature label Feb 3, 2025
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.

I only have small remarks left:

  • The author of a WP is now correctly shown as link (in the little info row next to the status). However, hovering over it does not trigger a HoverCard
  • When opening a user autocompleter (e.g to set an assignee), I can also see groups. Hovering over a group name triggers an empty hovercard which lays behind the dropdown. There should be no card at all
Bildschirmfoto 2025-02-04 um 08 58 47

// For hover cards to work within the auto completer, we have to ensure that the hover event can be properly
// triggered when mousing over the name. The easiest way to do this is to set it to inline-block.
.op-user-autocompleter--name.op-hover-card--preview-trigger
display: inline-block
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite understand why this is needed at all but it causes problems with long names which are simply cut off:

Bildschirmfoto 2025-02-04 um 08 59 32

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this property since I encountered weird behavior. When you hovered over a name in an autocompleter, the hover card would show up. But as soon as you traced over a space between words, it would disappear - only to re-appear shortly thereafter when you leave the space and enter the next word.

However, this no longer happens now. So there must have been another in-development-state present back then that was the cause for this buggy behavior. Thanks for questioning this, I can remove this hack!

The autocompleter hover cards only worked when there was no
search highlighting enabled. As soon as there were results,
the child spans were transformed and you could not hover over
them anymore, so cards did not trigger.

Setting these to `inline-block` fixes that issue.
* use cuprite
* get rid of unneeded empty grid setup (that is ignored)
* expect a location that exists
Yes, it has many conditions. But throwing in additional methods won't
help with reducing its complexity.
this is no longer needed
@EinLama EinLama force-pushed the feature/59925-show-user-popover-on-the-name branch from 5a24300 to 3eb1fa7 Compare February 4, 2025 08:54
@EinLama
Copy link
Contributor Author

EinLama commented Feb 4, 2025

The author of a WP is now correctly shown as link (in the little info row next to the status). However, hovering over it does not trigger a HoverCard

Thank you, fixed!

When opening a user autocompleter (e.g to set an assignee), I can also see groups. Hovering over a group name triggers an empty hovercard which lays behind the dropdown. There should be no card at all

That was a side-efffect of me removing the sibling logic. Fixed now so that hover cards are only shown for principals of type user.

@EinLama EinLama requested a review from HDinger February 4, 2025 08:57
@EinLama
Copy link
Contributor Author

EinLama commented Feb 4, 2025

The red spec is flaky, have seen this a couple of times 😵

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.

Nice job 👍 🌟

@EinLama EinLama merged commit d9cb693 into dev Feb 4, 2025
13 of 14 checks passed
@EinLama EinLama deleted the feature/59925-show-user-popover-on-the-name branch February 4, 2025 10:25
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.

2 participants