Skip to content

InputGroup fails if undefined or null passed as child #696

Description

@bedrich-schindler

Following examples fail due to undefined or null as child of InputGroup

<InputGroup label="Your favourite fruit">
  <SelectField
    label="Your favourite fruit"
    onChange={(e) => setFruit(e.target.value)}
    options={options}
    value={fruit}
  />
  <TextField
    label="Variety"
    placeholder="Eg. Golden delicious"
  />
  {null /* or undefined */}
  <Button label="Submit" />
</InputGroup>

This part of implementation should be fixed:

const validationState = children.reduce(
  (state, child) => {
    if (state === 'invalid' || (state === 'warning' && child.props.validationState === 'valid')) {
      return state;
    }
    return child.props.validationState ?? state;
  },
  null,
);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    • Status
      💡Ideas

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions