React-bootstrap-typeahead: Set input readOnly

Created on 13 Mar 2018  路  4Comments  路  Source: ericgio/react-bootstrap-typeahead

I'm using a multi-input Typeahead component, and I want to be able to click to remove previously selected elements (maintain this existing functionality), but _not_ type in the input field. The current "disabled" property almost does this, but it also prevents the selected elements from being deselected.

Most helpful comment

I think I've answered your question and I don't believe there are any bugs in terms of the current behavior, so I'm going to close this out. Feel free to re-open if you disagree.

All 4 comments

You can pass readOnly to the input via inputProps:

<Typeahead
  inputProps={{
    readOnly: true,
  }}
  multiple
  ...
/>

This will prevent typing in the input, but will not prevent the menu from opening when the component is focused, and users can therefore select additional items. That's potentially a bug.

I'm not entirely sure I understand the behavior you're after, however, since a true readonly input wouldn't allow the user to either add or remove selections.

Reading the spec, it actually looks like only input and textarea can be readonly, while select, among others, cannot.

So I think the current behavior actually seems correct in not allowing users to enter text but allowing selections.

I think I've answered your question and I don't believe there are any bugs in terms of the current behavior, so I'm going to close this out. Feel free to re-open if you disagree.

Thanks, this was exactly what I was looking for!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

damonmiller picture damonmiller  路  3Comments

SerdarSanri picture SerdarSanri  路  7Comments

ashanjayasundara picture ashanjayasundara  路  4Comments

DaveyEdwards picture DaveyEdwards  路  5Comments

derwaldgeist picture derwaldgeist  路  7Comments