Skip to content

FormChoice Doesn't allow for false as a value override #957

@CRiva

Description

@CRiva

In the react app I'm working on, I have controlled state for a form, so I wish to have one radio button be the true and another be the false like so (removed specific names for generic sake):

          <FormRow
            id='js-technical-resources'
            onChange={e => myFucntion(e.target.value)}
            stacked
            type='radio'
          >
            <FormChoice
              key='option 1'
              name='option 1'
              checked={!stateVariable}
              value={false}
            >
              Option 1
            </FormChoice>
            <FormChoice
              key='Option 2'
              name='Option 2'
              checked={stateVariable}
              value={!!true}
            >
              Option 2
            </FormChoice>
          </FormRow>

But this doesn't pass in false as the value when Option 1 is selected due to this computedValue in the FormChoice Component.

    const computedValue = value || children;

It computes to the {children} which in this case is just the string Option 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions