Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implicitly required form fields visual #487

Open
mbohal opened this issue Sep 7, 2023 · 2 comments · May be fixed by #581
Open

implicitly required form fields visual #487

mbohal opened this issue Sep 7, 2023 · 2 comments · May be fixed by #581
Labels
BC Breaking change feature
Milestone

Comments

@mbohal
Copy link
Contributor

mbohal commented Sep 7, 2023

For some form fields:

  • Those representing boolean value (Toggle, CheckboxField)
  • Those representing value from list (SelectField, Radio)

The semantics of required are different then for fields such as TextField. When TextField is left empty, it means the user did not specify value. When one of the above mentioned special fields is left untouched, it still carries a meaning (e.g. false).

The above mentioned special fields are therefore always required as it is impossible not to fill them. Accordingly, they should always be styled as required fields even when they do not have the required attribute.

The required attribute on boolean fields means "must be set to true" which is different from its meaning when used with for example a TextField. When the required attribute is used in this sense, it must be communicated by other means, (e.g. by adding (required) to the label or such).

Note that HTML <select multiple> can be left with no selected value, but RUI does not implement this.

@mbohal mbohal added the feature label Sep 7, 2023
@mbohal mbohal added this to The Board Sep 7, 2023
@github-project-automation github-project-automation bot moved this to 💡Ideas in The Board Sep 7, 2023
@mbohal mbohal added this to the v1.0.0 milestone Sep 7, 2023
@mbohal mbohal moved this from 💡Ideas to 🔖 To do in The Board Sep 7, 2023
@mbohal mbohal added the BC Breaking change label Sep 7, 2023
@mbohal
Copy link
Contributor Author

mbohal commented Jun 4, 2024

In a video call we did not find agreement on the concept of implicitly required.

The solution we agreed on is to separate required HTML attribute from presentation details. There should be another prop that will render field in the "required" visual.

I'm unsure if the new prop (something like renderRequired or such) should be available on all Form Elements or only on Toggle, CheckboxField, SelectField, Radio.

@adamkudrna
Copy link
Member

As I see it, I'd go with renderAsRequired on check fields (Toggle, CheckboxField, Radio) and on the SelectField.

Should both required and renderAsRequired be present, required would take precedence as it also adds the required HTML attribute.

@adamkudrna adamkudrna moved this from 🔖 To do to 🏗 In progress in The Board Nov 29, 2024
adamkudrna added a commit that referenced this issue Dec 3, 2024
Users may find themselves in a situation where the input is
not required (i.e. making the input checked), but they also
don't want to render the field as optional because not
choosing an option can be perfectly valid. For this case,
there is the `renderAsRequired` prop.

This affects `CheckboxField`, `Radio`, `SelectField`, and `Toggle`.
@adamkudrna adamkudrna moved this from 🏗 In progress to 👀 In review in The Board Dec 3, 2024
adamkudrna added a commit that referenced this issue Dec 3, 2024
Users may find themselves in a situation where the input is
not required (i.e. making the input checked), but they also
don't want to render the field as optional because not
choosing an option can be perfectly valid. For this case,
there is the `renderAsRequired` prop.

This affects `CheckboxField`, `Radio`, `SelectField`, and `Toggle`.

Closes #487
adamkudrna added a commit that referenced this issue Dec 6, 2024
Users may find themselves in a situation where the input is
not required (i.e. making the input checked), but they also
don't want to render the field as optional because not
choosing an option can be perfectly valid. For this case,
there is the `renderAsRequired` prop.

This affects `CheckboxField`, `Radio`, `SelectField`, and `Toggle`.

Closes #487
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC Breaking change feature
Projects
Status: 👀 In review
Development

Successfully merging a pull request may close this issue.

2 participants