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

Cap tag list of person hover cards #1920

Merged
merged 8 commits into from
May 16, 2024

Conversation

awarn
Copy link
Collaborator

@awarn awarn commented Apr 19, 2024

Description

Caps the maximum number of tags shown when hovering a person.
The same cap is applied for each group of tags individually.

Changes

  • New "cap" parameter on TagsList component.

Related issues

Resolves #1767

Copy link
Contributor

@ziggabyte ziggabyte left a comment

Choose a reason for hiding this comment

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

Hi! Nice work! This will be a solid improvement for the PersonHoverCard!

I'm leaving this as a comment, because I'm interested in hearing your thought process on one of my comments below, before approving or requesting changes!

hiddenTags
.slice(0, 3)
.map((tag) => tag.title)
.join(', ') + (hiddenTags.length > 3 ? ', ...' : '');
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious about the choice to cap the amount of tag titles visible in the tooltip. I would expect that the tooltip showed all the titles of all the tags that are not visible - so that the number that indicates how many hidden tags there are is the amount of tag titles that are shown in the tooltip.

How do you think about this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I must have turned this around in my head, somehow! Yes, it should display the number of remaining ones, let me fix that real quick.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alright, I think I misunderstood your question:
The reason I cap the number of titles shown in the tooltip is that otherwise it could be potentially massive. Which was the problem we tried to avoid for the hover card, so I assumed something similar here. That said, it could certainly by higher than just 3 titles.

Copy link
Contributor

Choose a reason for hiding this comment

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

I ran this by Josef and Victor on the design team and after a bit of discussions the direction they want this to go is to cap at 10 visible tags instead of 3, remove the tooltip on the "+X tags" and instead have that chip link to the person's profile page (where all tags are visible). Sounds ok?

isGrouped: boolean;
onUnassignTag?: (tag: ZetkinTag) => void;
tags: ZetkinTag[];
}> = ({ tags, isGrouped, onUnassignTag }) => {
}> = ({ cap = Infinity, isGrouped, onUnassignTag, tags }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have never seen or used Infinity before, so I read up on it, cool thing!

Comment on lines 38 to 41
const cappedTags = tags.slice(0, cap);
const hiddenTags = tags.slice(cap);
const isCapped = tags.length > cappedTags.length;
const tooltipTitle =
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like how clearly named these are and that you saved each thing in a constant instead of just using them inline!

Copy link
Contributor

@ziggabyte ziggabyte left a comment

Choose a reason for hiding this comment

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

Writing it here also to make it more clear:

I ran the matter of the tooltip by Josef and Victor on the design team and after a bit of discussions the direction they want this to go is to cap at 10 visible tags instead of 3, remove the tooltip on the "+X tags" and instead have that chip link to the person's profile page (where all tags are visible). :D

Copy link
Contributor

@ziggabyte ziggabyte left a comment

Choose a reason for hiding this comment

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

Looks great! 🥳 Only one annoying little detail though... I can fix it if you don't have the time/space to do it, and we can get this merged!

import { ZetkinTag } from 'utils/types/zetkin';
import { Box, Theme, Typography } from '@mui/material';
Copy link
Contributor

Choose a reason for hiding this comment

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

This is annoying but this line of import is external, so it belongs to the first group of imports. We have a pending PR for a linting rule that will do this for us eventually, but until then this needs to be moved up to the first import group :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Go right ahead and fix this if you want, it saves me a little brainpower!

chip: {
borderColor: theme.palette.grey[500],
borderRadius: '1em',
borderWidth: '1px',
color: theme.palette.text.secondary,
cursor: 'default',
cursor: ({ clickable }) => (clickable ? 'pointer' : 'default'),
Copy link
Contributor

Choose a reason for hiding this comment

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

sweet!

Copy link
Contributor

@ziggabyte ziggabyte left a comment

Choose a reason for hiding this comment

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

Nice work!! 💯 🥳

@ziggabyte ziggabyte merged commit a916fa2 into zetkin:main May 16, 2024
4 of 5 checks passed
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.

Person hover card breaks when there are lots of tags
2 participants