Support required form fields that only trigger invalid state after 1st user interaction/blur event #5246
Replies: 4 comments 13 replies
-
Component support & use casesHere are the components that I updated to use the new required logic, and were super easy to update/required no extra code to get working:
Here are the remaining components that will likely not have immediate required functionality:
@academo, @bfishel, @paul-tavares - please let me know whether this initial list would be immediately usable by your teams, and if not, what components from the 2nd list you would need! |
Beta Was this translation helpful? Give feedback.
-
Prop/API namingThis came up during our sync today when I demo'd my work and is very closely related to #4982. When I originally was spiking this out, I went with However, I'm aware this does highlight some confusion as with our @cchaos also suggested a more verbose API option, e.g. |
Beta Was this translation helpful? Give feedback.
-
Form label required indicatorWhen I demo'd this today, I originally had a I removed it after feedback from @cchaos that we don't necessarily want to enforce this indicator especially for forms where most or all fields are required. I wanted to start a discussion topic on it however since I believe @paul-tavares also voiced some strong opinions on UI/UX affordance for users before their submission. FWIW, I do think it's fairly easy for devs to add their own |
Beta Was this translation helpful? Give feedback.
-
Keep the
|
Beta Was this translation helpful? Give feedback.
-
We've recently had requests from @academo, @bfishel, and @paul-tavares on the subject of required form fields. Currently, EUI does not do any specific management around field requirements - when users pass in the
required
attribute, they get the default browser behavior which unfortunately flags empty inputs as:invalid
on initial page load (past related issue: #4710).For full context, historically (per @cchaos) we've had far more use-cases where either the entire form is requred or there are more required than optional fields. In those scenarios, leaving required fields as the default and instead marking optional fields where they exist has been the preferred UX (example article). We've also generally preferred whole form validation that occur on final submit.
However, I still think this is fairly useful functionality (which we can/should of course still provide UX guidance around) that I've wanted in the past while working on Enterprise Search, so I did a quick spike attempt at baking in
required
behavior that only triggered invalid states after the first userblur
event. I also wanted the required UX to integrate intoEuiFormRow
and color the label + automatically display an error message, so I did a little extra work around that.You can check out the PR here: #5244
And you can also test on the PR staging:
Here's a few unknowns left from my spike that I would love to get feedback on from the folks who want this feature as well as our designers/product stakeholders:
I'll start separate comments below for each topic to help with threading and resolution. Feel free to start more if you can think of other potential issues or discussion points!
Beta Was this translation helpful? Give feedback.
All reactions