You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add people-picker form associated custom elements spec (#3143)
* add form-based validation elements
* add initial draft of inclusion of form-associated custom elements in people-picker
* apply review suggestions
* apply review comments
* adds in the types of the form validation properties
* Update specs/mgt-people-picker.md
---------
Co-authored-by: Gavin Barron <[email protected]>
The mgt-people-picker component can be used as a form control in a form, and the form can be submitted with the attributes as part of the form data. It makes use of the form-associated custom elements API, which provides a new set of capabilities that make custom controls work like built-in form controls. The component will implement the form-associated behaviors to participate in form submission, validation, and other form-related behaviors. [Read more](https://docs.google.com/document/d/1JO8puctCSpW-ZYGU8lF-h4FWRIDQNDVexzHoOQ2iQmY/edit?pli=1#heading=h.2hgix04sc53t) about the form-associated custom elements API and [how to create custom form controls](https://css-tricks.com/creating-custom-form-controls-with-elementinternals/).
52
+
53
+
The following properties are used as part of the required field validation logic for the component.
54
+
55
+
56
+
| Property on the object | Description | Type of property |
|`required`| Determines if the required field validation is to be executed. When `true` the field is invalid if the the selectedPeople property contains zero items. |`boolean`|
59
+
|`selectedPeople`| Sets the selected people programmatically. |`array`||
60
+
|`disabled`| Sets whether the people picker is disabled. When disabled, the user is not able to search or select people. |`boolean`|
61
+
62
+
## Implementing the form-associated behaviors
63
+
64
+
The implementation of the form-associated custom elements will include the following:
65
+
66
+
### Identify the element as a form-associated custom element
67
+
68
+
The `mgt-people-picker` component is identified as a form-associated custom element by adding a static `formAssociated` property to the custom element class to tell the browser to treat the element like a form control.
### Providing access to the form control's internals
79
+
80
+
The component will implement the attachInternals() method on the element to get access to extra methods and properties for form controls, like setFormValue() and setValidity(). This method returns the `ElementInternals` object that provides access to the form control APIs.
81
+
82
+
It will also set the internal value of the control.
The mgt-people-picker will handle validation by using the setValidity() provided by the ElementInternals object, which you get by calling attachInternals() on your custom element, to indicate whether the element is currently valid or not.
In future versions of the `mgt-people-picker`, we plan to add more advanced validation features to give developers more control over the selection process and ensure that users select the correct number of people.
147
+
148
+
### Range Validation
149
+
150
+
We plan to add support for range validation. This will allow developers to specify a minimum and maximum number of people that can be selected. This will be useful in scenarios where there is a hard limit on the number of people that can be selected. For example, a developer could specify that at least 2 people and at most 5 people must be selected.
0 commit comments