Skip to content

feat(conversation): #COCO-5574 remove search text after select user#984

Open
Romu-C wants to merge 2 commits intodevelop-b2schoolfrom
feat/COCO-5574_remove-search-text-after-select-user
Open

feat(conversation): #COCO-5574 remove search text after select user#984
Romu-C wants to merge 2 commits intodevelop-b2schoolfrom
feat/COCO-5574_remove-search-text-after-select-user

Conversation

@Romu-C
Copy link
Contributor

@Romu-C Romu-C commented Mar 26, 2026

Description

This PR updates the conversation message recipient picker so that after selecting a recipient, the search input is cleared (and the search results are reset), aligning with ticket #COCO-5574.

Changes:

  • Add a resetSearch action to useSearchRecipients and expose resetSearchValue() from the hook.
  • Call resetSearchValue() after a recipient is selected in RecipientListEdit.

Fixes

(Enter here Jira or Redmine ticket(s) links)

Type of change

Please check options that are relevant.

  • Chore (PATCH)
  • Doc (PATCH)
  • Bug fix (PATCH)
  • New feature (MINOR)

Which packages changed?

Please check the name of the package you changed

  • admin
  • app-registry
  • archive
  • auth
  • cas
  • common
  • communication
  • conversation
  • directory
  • feeder
  • infra
  • portal
  • session
  • test
  • tests
  • timeline
  • workspace

Tests

  1. Describe here the tests you performed
  2. Step by step
  3. With expected results

Reminder

  • Security flaws

  • Performance impacts (think bulk !)

  • Unit tests were replayed

  • Unit tests were added and/or changed

  • I have updated the reminder for the version including my modifications

  • All done ! 😃

@sonarqubecloud
Copy link

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the conversation message recipient picker so that after selecting a recipient, the search input is cleared (and the search results are reset), aligning with ticket #COCO-5574.

Changes:

  • Add a resetSearch action to useSearchRecipients and expose resetSearchValue() from the hook.
  • Call resetSearchValue() after a recipient is selected in RecipientListEdit.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
conversation/frontend/src/features/message-edit/hooks/useSearchRecipients.tsx Adds reducer action + hook API to reset search input/results.
conversation/frontend/src/features/message-edit/components/RecipientListEdit.tsx Invokes the new reset function after recipient selection.
Comments suppressed due to low confidence (1)

conversation/frontend/src/features/message-edit/hooks/useSearchRecipients.tsx:22

  • The Action union includes { type: 'on' }, but the reducer has no case 'on' and this action isn't dispatched anywhere in the codebase. This is confusing and becomes a runtime crash if it’s ever dispatched; please either remove it from the union or implement the corresponding reducer case.
type Action =
  | { type: 'resetSearch' }
  | { type: 'onChange'; payload: string }
  | { type: 'isSearching'; payload: boolean }
  | { type: 'addResult'; payload: OptionListItemType[] }
  | { type: 'addApiResult'; payload: Visible[] }
  | { type: 'on'; payload: Visible[] }
  | { type: 'updateSearchResult'; payload: OptionListItemType[] }
  | { type: 'emptyResult'; payload: OptionListItemType[] };

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 185 to +187
await handleSelectRecipient(recipient);
setLoadingBookmarkIndex(undefined);
resetSearchValue();
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

handleRecipientClick updates loadingBookmarkIndex (and now resets the search) only on the success path. If handleSelectRecipient() rejects (e.g., getBookmarkById query fails), loadingBookmarkIndex will stay set and the error will be unhandled. Wrap the await in try/catch/finally so the loading state is always cleared, and decide whether resetSearchValue() should run only on success.

Suggested change
await handleSelectRecipient(recipient);
setLoadingBookmarkIndex(undefined);
resetSearchValue();
try {
await handleSelectRecipient(recipient);
resetSearchValue();
} catch (error) {
// eslint-disable-next-line no-console
console.error('Failed to select recipient', error);
} finally {
setLoadingBookmarkIndex(undefined);
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@jcbe-ode jcbe-ode left a comment

Choose a reason for hiding this comment

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

[low] Suis d'accord avec copilot. Voir si c'est faisale facilement, car c'est mineur.

…hRecipients.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

3 participants