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

Fixing issue 1612 & 1603 - PeoplePicker won't accept Multiple Users with the same name #1620

Merged
merged 1 commit into from
Sep 23, 2023
Merged

Fixing issue 1612 & 1603 - PeoplePicker won't accept Multiple Users with the same name #1620

merged 1 commit into from
Sep 23, 2023

Conversation

NishkalankBezawada
Copy link
Contributor

@NishkalankBezawada NishkalankBezawada commented Aug 10, 2023

Q A
Bug fix? [x]
New feature? [ ]
New sample? [ ]
Related issues? fixes #1612 & #1603

What's in this Pull Request?

Fixing Issue #1612
Fixing Issue #1603

Problem Statement

People picker wont accept users with same First Name & Last Name but with different LoginName/Emails.

Steps to reproduce

Added few Users in EntraID as below

First Name Last Name Email
John Smith john.smith.01@pm3q.onmicrosoft.com
John Smith john.smith.02@pm3q.onmicrosoft.com
John Smith john.smith.03@pm3q.onmicrosoft.com

With this, If we are selecting John Smith with email john.smith.01@pm3q.onmicrosoft.com at first, we are not able to add other Users with same names but with different emails as above.

Solution

In PeoplePickerComponent, onSearchFieldChanged after results are fetched, the results are sent to 'removeDuplicates' to the method, listContainsPersona

This method was just filtering with the names as below,

  private listContainsPersona = (persona: IPersonaProps, personas: IPersonaProps[]): boolean => {
    if (!personas || !personas.length || personas.length === 0) {
      return false;
    }
    return personas.filter(item => item.text === persona.text).length > 0;
  }

And with this reason, the next user is not getting accepted, as the below code returns true always
return personas.filter(item => item.text === persona.text).length > 0;

By making a change as below to also compare with secondaryText will get the users with same names and with different emails

  private listContainsPersona = (persona: IPersonaProps, personas: IPersonaProps[]): boolean => {
    if (!personas || !personas.length || personas.length === 0) {
      return false;
    }
    return personas.some(item => item.text === persona.text && item.secondaryText === persona.secondaryText);
  }

With this change, PeoplePicker will accept users with same First Name & Last Name but with different LoginName/Emails (Gif below)

MultipleUsersWithSameNamebutDifferentLoginNames

Thanks,
Nishkalank Bezawada

@NishkalankBezawada NishkalankBezawada changed the title Fixing issue 1612 - PeoplePicker won't accept Multiple Users with the same name Fixing issue 1612 & 1603 - PeoplePicker won't accept Multiple Users with the same name Aug 11, 2023
@sionjlewis
Copy link

Thank you @NishkalankBezawada.
Do you have any idea when your fix may be released for general use?

@NishkalankBezawada
Copy link
Contributor Author

Thank you @NishkalankBezawada.

Do you have any idea when your fix may be released for general use?

Hey @sionjlewis, The maintainers has to merge my PR into DEV so that you could use the nightly build. I'm not sure about the production release though. I'll keep you posted on this

@nateforsyth
Copy link

Hey team, been a month since the last update - any word on when this will hit general availability please? We have immediate need for this fix.

@NishkalankBezawada
Copy link
Contributor Author

Hey team, been a month since the last update - any word on when this will hit general availability please? We have immediate need for this fix.

Hi @joelfmrodrigues, Do you have any update on this.

Thanks,
Nishkalank

@joaojmendes
Copy link
Collaborator

Hi, @NishkalankBezawada. Thank you for your PR.

@joaojmendes joaojmendes self-requested a review September 23, 2023 11:40
@joaojmendes joaojmendes self-assigned this Sep 23, 2023
@joaojmendes joaojmendes added the status:fixed-next-drop Issue will be fixed in upcoming release. label Sep 23, 2023
@joaojmendes joaojmendes added this to the 3.16.0 milestone Sep 23, 2023
@joaojmendes joaojmendes merged commit fbe0e3f into pnp:dev Sep 23, 2023
1 check passed
@NishkalankBezawada NishkalankBezawada deleted the Issue-1612 branch September 23, 2023 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed-next-drop Issue will be fixed in upcoming release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants