microsoftgraph / microsoft-graph-toolkit

Authentication Providers and UI components for Microsoft Graph 🦒
https://docs.microsoft.com/graph/toolkit/overview
Other
921 stars 284 forks source link

[BUG] People picker: selectUsersById causes user dropdown to open up #3184

Open web265p3 opened 1 month ago

web265p3 commented 1 month ago

Describe the bug Whenever I use the function selectUserById of the people picker component, the dropdown to pick a user opens up.

To Reproduce Steps to reproduce the behavior:

  1. Create the people picker component. ie:

<mgt-people-picker ngDefaultControl name="people" id="MY_TEST_ID"> </mgt-people-picker>

  1. Call the selectUserById function:

(document.getElementById('MY_TEST_ID') as any).selectUsersById(['977c3cbe-e47e-xxxx-b92c-0739ad67ebbe']);

  1. The dropdown of the people picker opens, because the focus is caught.

Expected behavior The focus of the element should not be caught automatically just because selectUsersById is called. Usually a programmatical selection does not need additional user action.

Environment

Additional context I am using Angular and use the people picker as a custom element.

web265p3 commented 1 month ago

Just figured out that this does not happen in older versions. For example in 2.6.2 everything works fine. So this is a bug of the current version 4.2.1

musale commented 1 month ago

I can't quit figure out how you're using this control @web265p3. Please could you explain a little more how you're utilizing it as a custom element?

web265p3 commented 1 week ago

@musale Sorry for my late reply. To use the graph toolkit within my Angular application, I followed the steps from this Microsoft article:

After this steps, you can use the people picker within Angular.

The version 4.2.1 always opens the dropdown menu to pick users after calling the function "selectUsersById". This bug did not happen in older versions, so I just reverted my code to version 2.6.2, where the problem did not exist.

musale commented 6 days ago

Oh, I see what you mean @web265p3. The selectUsersById function is calling addPerson method which adds the found user ids and sets focus on the input field. I introduced this behaviour in this PR https://github.com/microsoftgraph/microsoft-graph-toolkit/pull/2792.

What I would suggest is:

Are these better ways to fix this for you or you have other ideas? v2.x.x is far back I would really want you to use the latest version of MGT too.