Skip to content

Conversation

@aleksandernsilva
Copy link
Contributor

@aleksandernsilva aleksandernsilva commented Nov 11, 2025

Proposed changes (including videos or screenshots)

This PR fixes an issue causing the UserAutoCompleteMultiple's avatar options to become misaligned.

Before
Screenshot 2025-11-11 at 17 30 00

After
Screenshot 2025-11-11 at 17 29 53

Issue(s)

FB-26

Steps to test or reproduce

  • Create new > Channel
  • Select a inexistent federated user as a member
  • Selected option should be misaligned

Further comments

Summary by CodeRabbit

  • New Features

    • Updated selected-user display in multi-user autocomplete to show an avatar/globe with name and support click-to-remove.
    • Added Storybook examples for the new selected-user chip.
  • Bug Fixes

    • Fixed the User Autocomplete's selected option alignment issue.
  • Tests

    • Added visual snapshots and accessibility tests for the new selected-user chip.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Nov 11, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Nov 11, 2025

🦋 Changeset detected

Latest commit: 61c1593

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Walkthrough

Adds a new UserAvatarChip component and integrates it into both standard and federated UserAutocomplete multiple-select components; includes Storybook stories, accessibility and snapshot tests, and a changeset marking a patch bugfix release for misaligned selected options.

Changes

Cohort / File(s) Summary
Changeset
\.changeset/neat-rats-grab.md
Adds a patch changeset for @rocket.chat/meteor describing a bugfix: "Fixes the User Autocomplete's selected option being misaligned".
New Component
apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.tsx
Adds UserAvatarChip default-exported React component: renders a Chip containing either a globe icon (federated) or UserAvatar, plus name/username; accepts standard Chip props plus federated, username, and optional name.
Stories & Tests
apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.stories.tsx, apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
Adds Storybook stories (Default, Federated, WithoutName, WithoutClickEvent) and tests: snapshot + jest-axe accessibility checks and verifies onClick forwarding.
Autocomplete integrations
apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultiple.tsx, apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultipleFederated.tsx
Replaces previous inline Chip/avatar+label rendering with UserAvatarChip; updates renderSelected to pass username and name (and use username-based cache lookup in federated variant).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Autocomplete as UserAutoCompleteMultiple
    participant Chip as UserAvatarChip
    participant Store as SelectedCache
    participant Handler as onRemove

    User->>Autocomplete: select option
    Autocomplete->>Store: add selected (username, name, federated)
    Autocomplete->>Chip: render(username, name, federated, onClick=onRemove)
    alt federated
        Chip->>Chip: show globe icon + name/username
    else local
        Chip->>Chip: show UserAvatar + name/username
    end
    User->>Chip: click remove
    Chip->>Handler: invoke onRemove(username)
    Handler->>Autocomplete: remove selected item
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas needing extra attention:
    • UserAvatarChip.tsx — prop typing, accessibility attributes, and visual layout.
    • Federated autocomplete (UserAutoCompleteMultipleFederated.tsx) — username-based cache lookup and option merging.
    • Tests (UserAvatarChip.spec.tsx) — jest-axe setup and click-forwarding assertion.

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • ggazzo
  • scuciatto

Poem

🐰 A tiny chip hopped into the view,
Swapped icons for avatars, tidy and true.
Federated or local, names now align,
I hopped, I tested — the UI's fine! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: User Autocomplete's avatar being misaligned' directly and specifically describes the main change made in this PR, which is fixing avatar misalignment in the UserAutoCompleteMultiple component.
Linked Issues check ✅ Passed The PR addresses the linked issue FB-26 by fixing the UserAutoCompleteMultiple component's avatar misalignment when handling non-existent federated users, preventing UI breakage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the avatar misalignment issue: introducing UserAvatarChip component and updating related UserAutoComplete components, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/autocomplete-avatar-missalined

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d8c521c and a0cd65a.

📒 Files selected for processing (3)
  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultiple.tsx (2 hunks)
  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultipleFederated.tsx (2 hunks)
  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (3)
apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultiple.tsx (2)

1-1: LGTM! Clean refactoring of imports.

The removal of unused Chip and Icon imports and addition of UserAvatarChip correctly reflects the component's new rendering approach.

Also applies to: 9-10


38-40: LGTM! Proper integration of UserAvatarChip.

The renderSelected implementation correctly maps the selected item's props (valueusername, labelname) and wires onRemove to the chip's onClick handler. Props spreading maintains the flexibility to pass layout props like mie from parent components.

apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultipleFederated.tsx (1)

2-2: LGTM! Clean refactoring of imports.

The removal of unused Box, Chip, and Icon imports and addition of UserAvatarChip aligns with the new rendering implementation.

Also applies to: 10-10


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

❌ Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.93%. Comparing base (4432e51) to head (61c1593).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37486      +/-   ##
===========================================
- Coverage    68.96%   68.93%   -0.04%     
===========================================
  Files         3357     3358       +1     
  Lines       114251   114240      -11     
  Branches     20536    20573      +37     
===========================================
- Hits         78795    78751      -44     
- Misses       33369    33399      +30     
- Partials      2087     2090       +3     
Flag Coverage Δ
e2e 57.42% <42.85%> (-0.01%) ⬇️
e2e-api 42.81% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aleksandernsilva aleksandernsilva marked this pull request as ready for review November 12, 2025 14:02
@aleksandernsilva aleksandernsilva requested a review from a team as a code owner November 12, 2025 14:02
@aleksandernsilva aleksandernsilva added this to the 7.13.0 milestone Nov 12, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.tsx (1)

11-20: Clean implementation with good fallback logic.

The component correctly handles both federated and non-federated users, and the name ?? username fallback ensures there's always displayable content.

Minor: Line 15's margin='none' appears redundant given that mis={4} already sets inline-start margin. Consider removing it for clarity:

-<Box is='span' margin='none' mis={4} verticalAlign='middle'>
+<Box is='span' mis={4} verticalAlign='middle'>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b27e9fb and d8c521c.

⛔ Files ignored due to path filters (1)
  • apps/meteor/client/components/UserAutoCompleteMultiple/__snapshots__/UserAvatarChip.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (6)
  • .changeset/neat-rats-grab.md (1 hunks)
  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultiple.tsx (2 hunks)
  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultipleFederated.tsx (2 hunks)
  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx (1 hunks)
  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.stories.tsx (1 hunks)
  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use descriptive test names that clearly communicate expected behavior

Applied to files:

  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Group related tests in the same file

Applied to files:

  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : All Playwright test files must be located under apps/meteor/tests/e2e/ and use the .spec.ts extension (e.g., login.spec.ts)

Applied to files:

  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (test, page, expect) consistently

Applied to files:

  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Maintain test isolation between test cases

Applied to files:

  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.{ts,tsx,js,jsx} : Write concise, technical TypeScript/JavaScript with accurate typing

Applied to files:

  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use expect matchers (toEqual, toContain, toBeTruthy, toHaveLength, etc.) instead of assert statements

Applied to files:

  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.{ts,tsx,js,jsx} : Avoid code comments in the implementation

Applied to files:

  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.{ts,tsx,js,jsx} : Follow DRY by extracting reusable logic into helper functions or page objects

Applied to files:

  • apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (8)
apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx (2)

1-21: Excellent test coverage with accessibility checks.

The combination of snapshot tests and accessibility testing for all Storybook stories provides comprehensive coverage for the component's visual output and accessibility compliance.


23-28: No issues found — the test correctly assumes Chip renders as button.

Fuselage's Chip component renders as an interactive element (button) when you provide an onClick prop. Since UserAvatarChip spreads props to Chip ({...props}), the onClick handler reaches Chip and causes it to render with button semantics. The test correctly uses screen.getByRole('button') and will work as written.

apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.tsx (1)

1-9: Well-structured type definition.

The component props correctly extend ComponentProps<typeof Chip>, ensuring all Chip props can be forwarded while adding the specific props needed for user avatar rendering.

apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.stories.tsx (1)

1-43: Comprehensive Storybook coverage.

The stories effectively demonstrate all key variations of the component: standard display, federated users, missing names, and non-interactive chips. This provides excellent documentation and visual testing coverage.

.changeset/neat-rats-grab.md (1)

1-5: LGTM!

The changeset correctly documents this as a patch-level bugfix with an appropriate description.

apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultiple.tsx (2)

1-1: Clean import updates.

The transition from inline Chip usage to the dedicated UserAvatarChip component improves code organization and reusability.

Also applies to: 9-9


38-40: Correct integration of UserAvatarChip.

The renderSelected callback properly maps the selected user data to UserAvatarChip props, maintaining the removal functionality through the onClick handler.

apps/meteor/client/components/UserAutoCompleteMultiple/UserAutoCompleteMultipleFederated.tsx (1)

2-2: Clean import updates.

Successfully migrated from inline Chip to the dedicated UserAvatarChip component.

Also applies to: 10-10

@aleksandernsilva aleksandernsilva force-pushed the fix/autocomplete-avatar-missalined branch from a0cd65a to d8c521c Compare November 12, 2025 18:28
@juliajforesti juliajforesti added the stat: QA assured Means it has been tested and approved by a company insider label Nov 12, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Nov 12, 2025
@kodiakhq kodiakhq bot merged commit c390d5c into develop Nov 12, 2025
48 checks passed
@kodiakhq kodiakhq bot deleted the fix/autocomplete-avatar-missalined branch November 12, 2025 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants