0

I am using the people picker component from the Microsoft Graph Toolkit, everything has been working for months with v1.3.5 and now I am upgrading to the latest version, v2.1.0, I get an error trying to set an initial user in the picker.

In the HTML I have

<mgt-people-picker id="siteOwnersPicker" type="person"></mgt-people-picker>

In my TypeScript I am setting an initial user like, where userId is a string with the Guid of the current user

const siteOwnersPicker: MgtPeoplePicker = document.querySelector('#siteOwnersPicker')
siteOwnersPicker.selectUsersById([userId]);

And I have updated my imports from

import { MgtPeoplePicker } from '@microsoft/mgt';

to

import { MgtPeoplePicker } from '@microsoft/mgt-components';

This compiles fine, but at runtime I get the error

siteOwnersPicker.selectUsersById is not a function

The documentation seems to indicate that the method signature hasn't changed, do I need more imports to bring in the file(s) with the method?

David
  • 116
  • 1
  • 10
  • I'm sure yet, but can you try using the default-selected-user-ids attribute instead? https://stackblitz.com/edit/default-selected?file=index.html – Nic Vogt May 07 '21 at 20:57

1 Answers1

0

Solved my problem.

I was importing the component from

import { MgtPeoplePicker } from '@microsoft/mgt-components';

when I actually needed to import the component from

import { MgtPeoplePicker } from '@microsoft/mgt';

don't know why it makes a difference but it does

David
  • 116
  • 1
  • 10