kettanaito / react-advanced-form

Functional reactive forms. Multi-layer validation, custom styling, field grouping, reactive props, and much more.
https://redd.gitbook.io/react-advanced-form
MIT License
217 stars 24 forks source link

Make "type" prop propagation explicit #335

Closed kettanaito closed 5 years ago

kettanaito commented 6 years ago

Environment

What

Current behavior

Whenever a new field is created, its type property is defaulted to "text" in both field state and field element. This makes field components like Textarea, Select and Radio abide by the type="text" validation rules, which is unexpected.

Expected behavior

Only Input component must have type="text" by default.

Why

Doing this allows to distinguish between field state's type and the type assigned to a field component. That means developers can assign their custom types to the field components to extend their validation logic, without spamming DOM elements within unsupported type attribute values.

How

  1. Make propagation of the type prop to a field element explicit. Do not inherit from the state.
  2. Assign necessary type prop on a field element explicitly using `enforceProps.
kettanaito commented 6 years ago

Implemented. Will be released under 1.6.