Grommet: Select component not working with `required` prop on Form field

Created on 26 Jun 2020  路  3Comments  路  Source: grommet/grommet

Expected Behavior

When putting a Select component inside of a FormField with the required prop the form should not submit unless there is a value in Select

Actual Behavior

The Form does not submit if the Select component has no value but it also does not submit if the Select component does have a value

URL, screen shot, or Codepen exhibiting the issue

Screen Shot 2020-06-26 at 4 29 31 PM

Codesandxox example https://codesandbox.io/s/grommet-v2-template-bv773?file=/index.js

Steps to Reproduce

1.) Choose a value from the Select component
2.) Click the Submit button

Your Environment

  • Grommet version: 2.14.0
  • Browser Name and version: Happens both in Chrome Version 83.0.4103.116 and Firefox 77.0.1
  • Operating System and version (desktop or mobile): Mac OS Catalina 10.15.5
Bug

All 3 comments

I think the name prop is missing in Select.

<Form onSubmit={({ value }) => {}}>
          <FormField name="test" label="Test" required>
-            <Select options={["one", "two", "three"]} />
+            <Select name="test" options={["one", "two", "three"]} />
          </FormField>
          <Button type="submit" primary label="Submit" />
</Form>

@netochaves Thanks that seemed to work! We'll be closing the issue now

Thank you @netochaves !

Was this page helpful?
0 / 5 - 0 ratings