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

popover: Fix user pop over not showing when clicked in channels /group settings #29898

Merged
merged 8 commits into from
May 17, 2024

Conversation

PieterCK
Copy link
Collaborator

@PieterCK PieterCK commented Apr 30, 2024

πŸ“‘ Overview

This PR aims to continue where #28820 has left off. The changes introduced in my PR are primarily fixes addressing the comments left by reviewer in the original PR.

Details of the original PR by Ecxtacy:

  • Added css fix for hovering effect on the X icon in user pills.
  • Added an optimization refactor to removePill function of input_pill.ts module as discussed in the CZO.
  • Fixed user pill related components to enable popover effect for user and user group pills in channel and group settings.

New changes in this PR is detailed in the PR comments I've highlighted in the code.

Fixes: #28687

Screenshots and screen captures:

Popovers on user and group pills in channel and group menu:

Relevant commits for this change:

  • input_pill: Pass user_id and group_id to render pill.
  • settings: Show user_card_popover when pill is clicked.
  • popovers: Refactor user_group_popover to work with pills.
  • settings: Show user_group_popover when pill is clicked.

Popovers on Channel/Stream settings:

Before After
image imageimage

Popovers on User Groups Settings:

Before After
image imageimage
X button hover effect:

Relevant commit for this change: css: Show 'x' button hover styling when hovered over 'x'.

Before:
X button focuses even only by hovering over the pill and not the button itself.

Screencast.from.04-05-24.16.06.44.webm

After:
X button only focuses if the cursor is on top of it.
image
image

Screencast.from.04-05-24.14.38.21.webm
Popover closing behavior:

Relevant commit for this change: hashchange: Fix popover not disappearing on overlay hash URL.

Before:
Clicking back button in browser doesn't hide popovers

Screencast.from.04-05-24.15.40.48.webm

After:

Screencast.from.04-05-24.15.57.19.webm
Screencast.from.04-05-24.15.57.53.webm
Impacted functions, no regression found:

toggle_user_group_info_popover() in user_group_popover.js still function on mentions in messages:
image

other user pills in group & channel setting:
image

Screencast.from.03-05-24.19.58.05.webm

πŸ§‘β€πŸ­ Concerns & Issue Encountered

  • inconsistency in user_group_pill.ts. I've pointed out the detail here
Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

@zulipbot
Copy link
Member

Hello @zulip/server-settings members, this pull request was labeled with the "area: settings UI" label, so you may want to check it out!

@PieterCK PieterCK force-pushed the issue-28687-pill-click-popover branch 2 times, most recently from 718ebcd to dde88c0 Compare April 30, 2024 15:04
@PieterCK
Copy link
Collaborator Author

umm, hello @ecxtacy. I think I did an oopsie by mentioning(@) you in the PR commits. I think you'll get notifications eveytime I push something here. I'm not sure whether that stays true even if I've changed the commit descriptions to not mention you. Sorry for that, let me know if you need help turning it off πŸ˜…

@PieterCK PieterCK marked this pull request as ready for review April 30, 2024 15:28
@alya
Copy link
Contributor

alya commented Apr 30, 2024

Thanks! To prepare this PR for review, you'll need to complete the self-review checklist, and reply to @sahil839 's comments on #28820, which had some questions. You can do so by commenting on this PR, including the original comment and your response.

@PieterCK PieterCK force-pushed the issue-28687-pill-click-popover branch from dde88c0 to eebcc51 Compare May 3, 2024 03:24
@@ -19,6 +19,8 @@ export type InputPillItem<T> = {
deactivated?: boolean;
status_emoji_info?: EmojiRenderingDetails & {emoji_alt_code?: boolean}; // TODO: Move this in user_status.js
should_add_guest_user_indicator?: boolean;
user_id?: number;
id?: number;
Copy link
Collaborator Author

@PieterCK PieterCK May 3, 2024

Choose a reason for hiding this comment

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

Original Review:

sahil: Why not group_id here instead of id?

Hi Sahil, it's because user_group_pill.ts used id instead if group_id. I also agree that it be group_id, consistent with user_id instead of just id. I can add it as a prep commit in this PR if you think we should make the change

relevant code in user_group_pill.ts:

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I think group_id is better and you can do that change in a prep commit.

@@ -1,4 +1,4 @@
<div class='pill {{#if deactivated}} deactivated-pill {{/if}}' tabindex=0>
<div class='pill {{#if deactivated}} deactivated-pill {{/if}}'{{#if user_id}}data-user-id="{{user_id}}"{{/if}}{{#if group_id}}data-group-id="{{group_id}}"{{/if}} tabindex=0>
Copy link
Collaborator Author

@PieterCK PieterCK May 3, 2024

Choose a reason for hiding this comment

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

Original Review:

sahil: I think we should name these attributes to data-user-id and data-group-id.

Changed it!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we use data-user-group-id in user_group.toggle_user_group_info_popover, so we might use data-user-group-id here as well.

});
$("body").on(
"click",
".view_user_profile, .pill-container.person_picker > .pill[data-user-id]",
Copy link
Collaborator Author

@PieterCK PieterCK May 3, 2024

Choose a reason for hiding this comment

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

In the original PR, there's a new separate function responsible for adding events listeners to the pill on stream and group settings. It was on line 885 in web/src/user_card_popover.js. However, it introduced a new bug where clicking some user pill pops up two popovers since it's targeted by both event listeners. So, I extended the selector to this event listener instead.

double popover bug:

Screenshot from 2024-04-30 20-46-58

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess that was due to the selector being used in the original PR. I imagine in future we would just add a common class to all the user pills when we want to show the popover for all pills with proper testing.

This seems fine for now though. Or maybe you can just use .person_picker .pill[data-user-id] selector.

@@ -130,6 +140,17 @@ export function register_click_handlers(): void {
blueslip.info("Unable to find user group in message" + message.sender_id);
}
});

// Show the user_group_popover when pill clicked in subscriber settings.
$("body").on("click", ".pill-container.person_picker > .pill[data-group-id]", (e) => {
Copy link
Collaborator Author

@PieterCK PieterCK May 3, 2024

Choose a reason for hiding this comment

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

Narrowed down the JQuery selector targeting the pill.
Original: .pill[group-id]

@PieterCK PieterCK force-pushed the issue-28687-pill-click-popover branch 2 times, most recently from 2fe5403 to f293cd6 Compare May 3, 2024 12:39
@PieterCK PieterCK force-pushed the issue-28687-pill-click-popover branch from f293cd6 to b6557e9 Compare May 3, 2024 12:49
@PieterCK PieterCK marked this pull request as draft May 3, 2024 13:02
@PieterCK PieterCK force-pushed the issue-28687-pill-click-popover branch 3 times, most recently from 4f15dfb to 00caaf0 Compare May 4, 2024 04:05
@PieterCK PieterCK changed the title popover: Fix user pop over not showing when clicked in stream/group settings popover: Fix user pop over not showing when clicked in channels /group settings May 4, 2024
@PieterCK PieterCK force-pushed the issue-28687-pill-click-popover branch from 00caaf0 to 02a8d15 Compare May 4, 2024 08:23
@PieterCK
Copy link
Collaborator Author

PieterCK commented May 4, 2024

Update: Edited the PR description, added new changes to the PR addressing reviews from the original PR and highlighted those changes through PR comments.

@PieterCK
Copy link
Collaborator Author

PieterCK commented May 4, 2024

Thanks! To prepare this PR for review, you'll need to complete the self-review checklist, and reply to @sahil839 's comments on #28820, which had some questions. You can do so by commenting on this PR, including the original comment and your response.

Sorry for notifying a sloppy PR, I've improved the PR description and commented on the new changes. I believe it's clearer now. Thank you as always! πŸ‘

@PieterCK PieterCK force-pushed the issue-28687-pill-click-popover branch 2 times, most recently from 6d5201c to 4e365c4 Compare May 4, 2024 09:24
@PieterCK PieterCK force-pushed the issue-28687-pill-click-popover branch 3 times, most recently from 4c72be7 to f8a7d51 Compare May 10, 2024 12:05
@PieterCK
Copy link
Collaborator Author

Update: Addressed reviews.

Having trouble trying to resolve the failing tests though, looks like it failed during provisioning. Any advice?
@sbansal1999 @sahil839

@sbansal1999
Copy link
Collaborator

sbansal1999 commented May 10, 2024

Yeah, looks like some issue during provisioning (can happen sometimes; nothing to worry about). You can re-run the tests by force-pushing your commits again.

Do it by amending your last commit's message using git commit --amend and then saving the commit message without making any changes. After that you can do a force push, which will trigger the tests again.

@PieterCK PieterCK force-pushed the issue-28687-pill-click-popover branch 2 times, most recently from 6c28e20 to 587d6d2 Compare May 11, 2024 05:54
@PieterCK
Copy link
Collaborator Author

PieterCK commented May 11, 2024

Aha, all good. Thanks!

@sahil839
Copy link
Collaborator

Code looks good. @alya this is ready for testing.

A couple of points -

  • We still change the color of pill to green on clicking on them.
  • This PR also adds code to show the pills when clicking on pills in a person type custom profile field, like Mentor field in "Profile" panel or manage user form in development environment due to elements using same class, but I guess that should be fine.

@sahil839
Copy link
Collaborator

Also, there is a PR #24334, which adds support for opening the popover for all the pills. This PR can be followed by completing that PR.

@alya
Copy link
Contributor

alya commented May 14, 2024

@PieterCK Please bump for my review once conflicts are resolved.

PieterCK and others added 8 commits May 17, 2024 15:58
Added new utility function to hash_parser to dynamically
detect the hash category of an URL. This is intended to
reduce the need of adding more adhoc hash_parser utility
functions.
When input pills are hovered, the 'x' button is highlighted.
This commit ensures that 'x' button is highlighted only if the
'x' button is hovered, not anywhere else on the pill.

Author: ecxtacy <[email protected]>.
Changed UserGroupPill's 'id' key to 'group_id' because
UserPill uses 'user_id' instead of only id.
While rendering input pills in input_pills.create function,
pass in the user_id or group_id accordingly.
Display the id as an html attribute in input_pill.hbs.

Co-authored-by: Pieter CK <[email protected]>.
Add a 'click' event listener to the user pills in
stream and group settings which toggles the
user_card_popover.

Co-authored-by: PieterCK <[email protected]>.
Refactored hashchanged() so that popover.hide_all()
is executed before checking is_overlay_hash() to close
popovers when the user changes hash but still on overlay.
Add 'click' event listener to the pills in stream settings
to toggle the user_group_info_popover.

Fixes zulip#28687.

Co-authored-by: Pieter CK <[email protected]>.
The removePill function of input_pill module uses a for loop
for iterating and finding the required pill.
Replace the for loop with inbuilt findIndex function for efficiency.

Authored-by: Dhruv Chouhan <[email protected]>.
@PieterCK PieterCK force-pushed the issue-28687-pill-click-popover branch from 587d6d2 to fc4a014 Compare May 17, 2024 09:26
@PieterCK
Copy link
Collaborator Author

Resolved merge conflict. @alya this is ready for testing

@alya
Copy link
Contributor

alya commented May 17, 2024

Works for me in manual testing!

@alya alya added integration review Added by maintainers when a PR may be ready for integration. and removed maintainer review PR is ready for review by Zulip maintainers. labels May 17, 2024
@alya
Copy link
Contributor

alya commented May 17, 2024

@timabbott This PR addresses @sahil839 's feedback on an earlier PR.

@timabbott timabbott merged commit 6af748f into zulip:main May 17, 2024
7 checks passed
@timabbott
Copy link
Sponsor Member

Merged, thanks @PieterCK and @sahil839!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: settings UI area: settings (user groups) User groups related settings issues integration review Added by maintainers when a PR may be ready for integration. priority: high size: L
Projects
Development

Successfully merging this pull request may close these issues.

Clicking on user or group pill in stream/group settings should open user/group card
7 participants