react-bootstrap-typeahead icon indicating copy to clipboard operation
react-bootstrap-typeahead copied to clipboard

Typeahead should add 'is-valid' and 'is-invalid' classes to its wrapper div when validating

Open tophboogie opened this issue 3 years ago • 2 comments

Hi, First off thanks for writing a great piece of software :)

When passing the isValid or isInvalid props to Typeahead, it would be great if it added the bootstrap classes 'is-valid' or 'is-invalid' to the typeahead wrapper div. This way, Form.Control.Feedback components would hide and display automatically when validating the form. Unless I am missing something, right now they need to be manually managed.

I looked into the Bootstrap 5 CSS and the feedback visibility is managed by

.is-invalid~.invalid-feedback { display: block; }

So for now I am manually adding these classes to the wrapper div in order to show the feedback, like so:

<Form.Group>
<Typeahead ... isInvalid={isTypeaheadInvalid} className={isTypeaheadInvalid ? 'is-invalid' : ''}  />
<Form.Control.Feedback type='invalid'>No {displayName} Selected!</Form.Control.Feedback>
</Form.Group>

This is working well but it seems like something that the component should just do on its own. Thanks!

tophboogie avatar Mar 26 '23 03:03 tophboogie

Hey @tophboogie, thanks for the feature request. Added in v6.1.0

ericgio avatar Mar 28 '23 08:03 ericgio

Awesome, thanks!

tophboogie avatar Apr 07 '23 18:04 tophboogie