rafaelmotta/react-native-tag-select

How to toggle itemsSelected on maxSelected

Opened this issue · 2 comments

Hey..!
i want to toggle value of this.tag.itemsSelected on selection more than one value.
Simply i mean that if a user select one item and then he selecte the other one the item should automatically toggle and only second value should be selected.
#thanks in advance.....

same issue

i create a workaround changing the handleSelectItem of TabSelect.js
` handleSelectItem = (item) => {
const key = item[this.props.keyAttr] || item

const value = []
const found = this.state.value[key]

// Item is on array, so user is removing the selection
// if (found) {
//   delete value[key]
// } else {
//   // User is adding but has reached the max number permitted
//   if (this.props.max && this.totalSelected >= this.props.max) {
//     if (this.props.onMaxError) {
//       return this.props.onMaxError()
//     }
//   }

//  
// }
value[key] = item
return this.setState({ value }, () => {
  if (this.props.onItemPress) {
    this.props.onItemPress(item)
  }
})

}`