microsoft-graph-toolkit icon indicating copy to clipboard operation
microsoft-graph-toolkit copied to clipboard

Add Typescript Typing for "selectionChanged" event

Open qingwang96 opened this issue 3 years ago • 4 comments

For the "selectionChanged" event on PeoplePicker component and others such as TeamsChannelPicker, the Typescript typing for the event property is not specified past the global React "Event" type.

Could somebody help to clarify the expected event structure in Typescript?

From "react.ts" in generated node_modules:

export type PeoplePickerProps = {
	groupId?: string;
	type?: PersonType;
	groupType?: GroupType;
	transitiveSearch?: boolean;
	people?: IDynamicPerson[];
	selectedPeople?: IDynamicPerson[];
	defaultSelectedUserIds?: string[];
	placeholder?: string;
	selectionMode?: string;
	showMax?: number;
	disabled?: boolean;
	templateContext?: TemplateContext;
	mediaQuery?: ComponentMediaQuery;
	selectionChanged?: (e: Event) => void;
}

qingwang96 avatar Jun 23 '21 00:06 qingwang96

Hello qingwang96, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

msftbot[bot] avatar Jun 23 '21 00:06 msftbot[bot]

@qingwang96

Yeah seems like there is some limitation with a purely js react custom events.

Here is a quick sample, of what we expect ts: selectionChangedEvent

And here is the basic structure for all of our CustomEvents. I think you'll mainly be concerned with the "detail" : https://github.com/microsoftgraph/microsoft-graph-toolkit/blob/d9ced8455bcdf3bff266270668441900f89f61d2/packages/mgt-element/src/components/baseComponent.ts#L184-L196

Hope this helps in the meantime

vogtn avatar Jun 23 '21 02:06 vogtn

At the meantime, we should investigate to implement this on mgt.

beth-panx avatar Jun 24 '21 16:06 beth-panx

It looks like web component analyzer will support what we need to make this fly in the future based on: https://github.com/runem/web-component-analyzer/issues/169 and https://github.com/runem/web-component-analyzer/pull/157

I've raised https://github.com/runem/web-component-analyzer/issues/248 to see if this is going to be addressed soon.

gavinbarron avatar Aug 24 '22 19:08 gavinbarron