affinipay / react-bootstrap-autosuggest

A modern combo-box built for React and Bootstrap
https://affinipay.github.io/react-bootstrap-autosuggest/
ISC License
56 stars 18 forks source link

Input field overrides className parameter - but only sometimes #5

Open viridia opened 8 years ago

viridia commented 8 years ago

I'm passing a 'className' attribute to the Autosuggest widget so that I can customize the width, but I see odd behavior when I do this. First, here's how I am calling it:

      <Autosuggest
          className={className}
          placeholder={placeholder}
          datalist={this.state.datalist}
          datalistOnly
          datalistPartial
          onSearch={this.onSearch}
          itemReactKeyPropName="username"
          itemSortKeyPropName="username"
          itemValuePropName="label" />

Also, I have set up my search callback to return no results if the input string is <2 characters. Given that, here's what I see:

trevorr commented 8 years ago

The className property of the Autosuggest component is applied (somewhat arbitrarily) to the input element (as opposed to the top-level div). Is that what you're expecting? Depending on settings like whether the toggle is visible (which controls whether an input group div wraps the input element), you'll have a variable number of divs wrapping the input. As in #4, you can force the presence of the input group regardless of the toggle visibility by using a setting such as bsSize.

Since CSS doesn't have parent selectors, it might be better (and more intuitive) if I moved the className usage to the (unconditionally rendered) top-level div. It's a breaking change, but I doubt it would affect anyone at this point. Let me know if you think this will help.