Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Fix 'required' prop for non-empty chip sets. #315

Merged
merged 2 commits into from
Apr 26, 2020

Conversation

benwiley4000
Copy link
Contributor

The required prop triggers undesired validation errors when chips are entered, since the FormControl context tells the input field that text input is required for submission.

Screen Shot 2020-04-22 at 2 28 27 PM

This change sets the FormControl's required state only when the list of chips is empty. To make sure the asterisk always appears when desired, I'm passing the required prop to the InputLabel component.

@coveralls
Copy link

coveralls commented Apr 22, 2020

Coverage Status

Coverage increased (+0.08%) to 84.958% when pulling 0dcbc1f on benwiley4000:fix-required into aebb65c on TeamWertarbyte:master.

src/ChipInput.js Outdated
@@ -576,7 +576,7 @@ class ChipInput extends React.Component {
[classes.marginDense]: other.margin === 'dense'
})}
error={error}
required={required}
required={chips.length ? undefined : required}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be changed to chips.length === 0 so that we know what this is intended to do. Let the minifier minify the code.

@leMaik
Copy link
Member

leMaik commented Apr 22, 2020

Thank you for your first contribution, @benwiley4000! 🎉

@leMaik leMaik merged commit 9801cda into TeamWertarbyte:master Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants