fast icon indicating copy to clipboard operation
fast copied to clipboard

rfc: Migrate FormAssociated components to @open-wc/form-control

Open nicholasrice opened this issue 2 years ago • 0 comments

💬 RFC

@open-wc/form-control is an open-source library designed to assist authors in writing custom-element form controls. It leverages the ElementInternals platform feature for form-association, and requires a ElementInternals polyfill for browsers that do not support ElementInternals.

Should FAST refactor its form-component offerings to be built off of @open-wc/form-control?

🔦 Context

FAST currently uses a proprietary FormAssociated and FormAssociatedCheckbox mixin to bring form-association to specific components offered from @microsoft/fast-foundation. These features work fundamentally differently than @open-wc/form-control in that they leverage a proxy input element to connect the control to the form for browsers that don't support ElementInternals. The API surface of FormAssociated is also not as robust as FormControlMixin from @open-wc/form-control and does not offer abstractions for custom constraint validators.

Refactoring @microsoft/fast-foundation's Form controls to leverage @open-wc/form-control poses several benefits for FAST:

  1. Reduces maintenance costs FAST.
  2. Demonstrates support for the @open-wc community.
  3. The API of FormControlMixin is more robust and IMO more intuitive for component development.
  4. Does not rely on proxy-element patterns, which add substantial behavioral differences depending on the client.

Risks:

  1. It requires adding a dependency to @microsoft/fast-foundation which comes with the usual dependency risks
  2. Resources dedication to migrating and testing components

References

https://github.com/microsoft/fast/issues/5678#issuecomment-1213573769

nicholasrice avatar Aug 19 '22 17:08 nicholasrice