Giter VIP home page Giter VIP logo

react-native-multiple-select's Introduction

react-native-multiple-select

npm Downloads Licence

Simple multi-select component for react-native (Select2 for react-native).

multiple single

Important notice

I've been super busy with work and other projects lately that I really don't have enough time to dedicate to this project. If you would like to maintain this project, you can drop me an email. Thanks.

Installation

$ npm install react-native-multiple-select --save

or use yarn

$ yarn add react-native-multiple-select

Usage

Note: Ensure to add and configure react-native-vector-icons to your project before using this package.

You can clone and try out the sample app or you can try sample

The snippet below shows how the component can be used

// import component
import React, { Component } from 'react';
import { View } from 'react-native';
import MultiSelect from 'react-native-multiple-select';

const items = [{
    id: '92iijs7yta',
    name: 'Ondo'
  }, {
    id: 'a0s0a8ssbsd',
    name: 'Ogun'
  }, {
    id: '16hbajsabsd',
    name: 'Calabar'
  }, {
    id: 'nahs75a5sg',
    name: 'Lagos'
  }, {
    id: '667atsas',
    name: 'Maiduguri'
  }, {
    id: 'hsyasajs',
    name: 'Anambra'
  }, {
    id: 'djsjudksjd',
    name: 'Benue'
  }, {
    id: 'sdhyaysdj',
    name: 'Kaduna'
  }, {
    id: 'suudydjsjd',
    name: 'Abuja'
    }
];

class MultiSelectExample extends Component {

  state = {
    selectedItems : []
  };

  
  onSelectedItemsChange = selectedItems => {
    this.setState({ selectedItems });
  };

  render() {
    const { selectedItems } = this.state;

    return (
      <View style={{ flex: 1 }}>
        <MultiSelect
          hideTags
          items={items}
          uniqueKey="id"
          ref={(component) => { this.multiSelect = component }}
          onSelectedItemsChange={this.onSelectedItemsChange}
          selectedItems={selectedItems}
          selectText="Pick Items"
          searchInputPlaceholderText="Search Items..."
          onChangeInput={ (text)=> console.log(text)}
          altFontFamily="ProximaNova-Light"
          tagRemoveIconColor="#CCC"
          tagBorderColor="#CCC"
          tagTextColor="#CCC"
          selectedItemTextColor="#CCC"
          selectedItemIconColor="#CCC"
          itemTextColor="#000"
          displayKey="name"
          searchInputStyle={{ color: '#CCC' }}
          submitButtonColor="#CCC"
          submitButtonText="Submit"
        />
        <View>
          {this.multiSelect.getSelectedItemsExt(selectedItems)}
        </View>
      </View>
    );
  }
}

The component takes 3 compulsory props - items, uniqueKey and onSelectedItemsChange. Other props are optional. The table below explains more.

Props

Prop Required Purpose
altFontFamily No (String) Font family for searchInputPlaceholderText
canAddItems No (Boolean) Defaults to "false". This allows a user to add items to the list of items provided. You need to handle adding the new items in the onAddItem function prop. Items may be added with the return key on the native keyboard.
displayKey No (String) Defaults to "name". This string will be used to select the key to display the objects in the items array
fixedHeight No (Boolean) Defaults to false. Specifies if select dropdown take height of content or a fixed height with a scrollBar (There is an issue with this behavior when component is nested in a ScrollView in which scroll event will only be dispatched to parent ScrollView and select component won't be scrollable). See this issue for more info.
filterMethod No (String) Defaults to "partial". options: ["partial", "full"] Choose the logic on how the system filters items based on searchTerm. partial: checks all individual words and if at least one word matches will include that item. full: checks to ensure the item contains the full substring of searchterm in order minus any leading or trailing spaces.
flatListProps No (Object) Properties for the FlatList. Pass any property that is required on the FlatList of the dropdown menu
fontFamily No (String) Custom font family to be used in component (affects all text except searchInputPlaceholderText described above)
fontSize No (Number) Font size for selected item name displayed as label for multiselect
hideDropdown No (Boolean) Defaults false. Hide dropdown menu with a cancel, and use arrow-back
hideSubmitButton No (Boolean) Defaults to false. Hide submit button from dropdown, and rather use arrow-button in search field
hideTags No (Boolean) Defaults to false. Hide tokenized selected items, in case selected items are to be shown somewhere else in view (check below for more info)
searchIcon No (Element, Object, boolean, Function) Element or functional component to change the Search Icon
itemFontFamily No (String) Font family for each non-selected item in multi-select drop-down
itemFontSize No (Number) Font size used for each item in the multi-select drop-down
itemTextColor No (String) Text color for each non-selected item in multi-select drop-down
items Yes (Array, control prop) List of items to display in the multi-select component. JavaScript Array of objects. Each object must contain a name and unique identifier (Check sample above)
noItemsText No (String) Text that replace default "no items to display"
onAddItem No (Function) JavaScript function passed in as an argument. The function is called everytime a new item is added, and receives the entire list of items. Here you should ensure that the new items are added to your provided list of items in addition to any other consequences of new items being added.
onChangeInput No (Function) JavaScript function passed in as an argument. The function is called everytime TextInput is changed with the value.
onClearSelector No (Function) JavaScript function passeed in as an argument. The function is called everytime back button is pressed
onSelectedItemsChange Yes (Function) JavaScript function passed in as an argument. The function is to be defined with an argument (selectedItems). Triggered when Submit button is clicked (for multi select) or item is clicked (for single select). (Check sample above)
onToggleList No (Function) JavaScript function passed in as an argument. The function is called everytime the multiselect component is pressed
searchInputPlaceholderText No (String) Placeholder text displayed in multi-select filter input
searchInputStyle No (Object) Style object for multi-select input element
selectText No (String) Text displayed in main component
selectedText No (String) Text displayed when an item is selected can be replaced by any string
selectedItemFontFamily No (String) Font family for each selected item in multi-select drop-down
selectedItemIconColor No (String) Color for selected check icon for each selected item in multi-select drop-down
selectedItemTextColor No (String) Text color for each selected item in multi-select drop-down
single No (Boolean) Toggles select component between single option and multi option
styleDropdownMenu No (Style) Style the view of the dropdown menu
styleDropdownMenuSubsection No (Style) Style the inner view of the dropdown menu
styleIndicator No (Style) Style the Icon for indicator
styleInputGroup No (Style) Style the Container of the Text Input Group
styleItemsContainer No (Style) Style the Container of the items that are displayed in a list
styleListContainer No (Style) Style the Container of main list. See [this issue] (#12)
styleMainWrapper No (Style) Style the Main Container of the MultiSelector
styleRowList No (Style) Style the Row that is displayed after you
styleSelectorContainer No (Style) Style the Container of the Selector when user clicks on the dropdown
styleTextDropdown No (Text Style) Style text of the Dropdown
styleTextDropdownSelected No (Text Style) Style text of the Dropdown selected
styleTextTag No (Text Style) Style text of the tag
submitButtonColor No (String) Background color for submit button
submitButtonText No (String) Text displayed on submit button
tagBorderColor No (String) Border color for each selected item
tagContainerStyle No (Style) Style the container of the tag view
tagRemoveIconColor No (String) Color to be used for the remove icon in selected items list
tagTextColor No (String) Text color for selected items list
textColor No (String) Color for selected item name displayed as label for multiselect
textInputProps No (Object) Properties for the Text Input. Pass any property that is required on the text input
uniqueKey Yes (String) Unique identifier that is part of each item's properties. Used internally as means of identifying each item (Check sample below)
selectedItems No (Array, control prop) List of selected items keys . JavaScript Array of strings, that can be instantiated with the component
removeSelected No (Boolean) Filter selected items from list to be shown in List

Note

  • Tokenized selected items can be displayed in any other part of the view by adding a ref to the MultiSelect component like so ref={(component) => { this.multiSelect = component }}. Then add this to any part of the screen you want the tokens to show up: this.multiSelect.getSelectedItemsExt(selectedItems). The selectedItems argument passed into the above mentioned method is the same selectedItems passed as the main component selected items prop. (See example above).

  • If users shouldn't be able to select any of the items in the dropdown list, set a disabled key to true in the item. Such item will be rendered in gray and won't be clickable.

  • When using the single prop, selectedItems should still be passed in as an array of selected items keys. Also, when an item is selected in the single mode, the selected item is returned as an array of string.

  • The items props must be passed as an array of objects with a compulsory name key present in each object as the name key is used to display the items in the options component.

  • filterMethod partial example: searchTerm = "University of New" will return "University of New York", "University of New Orleans", "The University of New York" as well as "University of Columbia" and "New England Tech" due to partial matches.

  • filterMethod full example: searchTerm = "University of New" will return" University of New York", "University of New Orleans", "The University of New York" because all three contain the substring "University of New"

Removing all selected items

To use, add ref to MultiSelect component in parent component, then call method against reference. i.e.

<MultiSelect
  ref={c => this._multiSelect = c}
  ...
/>

clearSelectedCategories = () => {
   this._multiSelect._removeAllItems();
};

Contributing

Contributions are welcome and will be fully credited.

Contributions are accepted via Pull Requests on Github.

Pull Requests

  • Document any change in behaviour - Make sure the README.md and any other relevant documentation are kept up-to-date.

  • Consider our release cycle - We try to follow SemVer v2.0.0. Randomly breaking public APIs is not an option.

  • Create feature branches - Don't ask us to pull from your master branch.

  • One pull request per feature - If you want to do more than one thing, send multiple pull requests.

  • Send coherent history - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

Issues

Check issues for current issues.

Contributors

Here is list of CONTRIBUTORS

License

The MIT License (MIT). Please see LICENSE for more information.

react-native-multiple-select's People

Contributors

ajangi avatar arslbbt avatar augustoalegon avatar benomatis avatar bubenkoff avatar crcnum4 avatar creedmangrum avatar dependabot[bot] avatar donedgardo avatar enieber avatar jaydeepk3 avatar jbbpatel94 avatar martincamen avatar nikitabuyevich avatar nycolassm avatar paitoanderson avatar psobhanlo avatar pwoltman avatar rickemery avatar robertqin86 avatar rpompeo avatar sushilshrestha avatar syedtayyabulmazhar avatar toystars avatar vbranco avatar ziyafenn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-multiple-select's Issues

Multiple Select is not working if is inside a ScrollView

Issue summary

Add a short description of issue, preferably, a sentence.

I am currently working with a Multiple-Select library. But I can't use it inside a ScrollView. It is not displaying.

Library versions

List the version of react-native and multi-select in use as below

react-native: 0.51.0
react-native-multiple-select: 0.3.0

Steps to Reproduce

(Write your steps here:)

  1. Just try put the multiple select inner the scroll view

Expected Behavior

(Write what you thought would happen.)
The component is working in a ScrollView.

Actual Behavior

The component don't show up.
(Write what happened. Add screenshots!)

Reproducible Code

(Paste exact code snippet and instructions to reproduce the issue.)

Android fixHeight error with parent ScrollView

The fixHeight doesnot work on andorid when there is parent scrollView present.
The whole component scrolls instead of just the data. This is problem only on android devices and works fine for iOS devices.
How to solve this problem?

Scrolling issue

sorry for opening another issue :D
so the issue is if MultiSelect component is inside a scrollview then ItemSelection windows scroll doesnt work and if i remove the scrollview then if selected items are taking more space than available screen then there is not way to see all the selected items as selected item windows itself is not scrollable

Cannot close selection dropdown after first use on Android

Great multiple selection component!

I'm having a problem on Android though (devices and emulators) using version 0.3.0:

  1. Open multiple select and choose tags.
  2. Close dropdown. (Not using submit button due to this issue.)
  3. Open multiple select. (This requires tapping a little high because the height appears to change?)
  4. Select tags.
  5. Unable to close multiple select by tapping anywhere.

react-natvie-multiple-select-not-closing

Code extract:

         <View style={{ flex: 1 }}>
            <MultiSelect
              hideSubmitButton
              hideTags
              items={this.props.tags}
              uniqueKey="id"
              ref={(component) => {
                this.multiSelect = component;
              }}
              fixedHeight={true}
              onSelectedItemsChange={this.onSelectedTagsChanged}
              selectedItems={this.state.selectedTagIds}
              selectText="List tags"
              searchInputPlaceholderText="Search tags..."
              tagRemoveIconColor={colours.brandPrimary}
              tagBorderColor={colours.brandPrimary}
              tagTextColor={colours.brandPrimary}
              selectedItemTextColor="#CCC"
              selectedItemIconColor="#CCC"
              itemTextColor="#000"
              searchInputStyle={{ color: "#CCC" }}
              submitButtonColor="#CCC"
              submitButtonText="Select"
            />
          </View>

DropDown list is not visible

Please can you help me out with my issue I have posted the issue on this link https://stackoverflow.com/questions/46646491/multiselect-in-react-native. I am trying to implement your component, thank you for sharing this amazing component. but I got some problem implementing it.
Actually i am fetching the data from API in the JSON format, my data would be somewhat like this [{"id":"14","name":"Ondo"},{"id":"15","name":"Oguโ€Œโ€‹n"},{"id":"16","nameโ€Œโ€‹": "Calabar"}]
and am saving this data to state. And the state is passed to the Item prop of multiselect. But i am not able to get the list of name in dropdown it shows the message as "No item to display". According to your doc items should contain the array of object which is the same i am passing to it. but still unable to view the list.

Auto close selection dropdown after press outside.

Issue summary

Auto close selection dropdown after press outside.

Library versions

List the version of react-native and multi-select in use as below
"react-native": "0.47.2",
"react-native-multiple-select": "^0.3.0",

Help wanted

I think the dropdown list should be close when press outside. First, open the dropdown list, it will onFocus into search input. And when onBlur search Input so the dropdown list will close.
screen shot 2018-01-15 at 9 54 07 pm

Toggle Button Issue

Issue summary

DropDown does not always shows when you click on ToggleButton (arrow-down ou arrow-right). But when you click multiple random times it works. It is happening both iOS and Android.

Library versions

"expo": "^27.0.1",
"react": "16.3.1",
"react-native": "~0.55.2",
"react-native-multiple-select": "^0.4.4",

Steps to Reproduce

  1. Click on the right arrow:
    image
  2. it doesn't always works and sometimes the button keeps the opacity
    image
  3. When it keeps the opacity, you can focus another inputText and the DropDown is toggled

Expected Behavior

DropDown always toggling when the arrow button is pressed.

Actual Behavior

DropDown toggles or not in unexpected ways when you press the arrow button

Reproducible Code

<SelectMultiple
items={options}
uniqueKey={"id"}
ref={component => {
this.multiSelect = component;
}}
onSelectedItemsChange={(values) => this.formChange(key,values)}
selectedItems={value}
selectText="Selecione uma ou vรกrias opรงรตes"
searchInputPlaceholderText="Digite o item a ser pesquisado..."
tagRemoveIconColor="#CCC"
tagBorderColor="#CCC"
tagTextColor="#CCC"
displayKey="name"
submitButtonColor="#CCC"
submitButtonText="Submit"
canAddItems={true}
onAddItem={(value) => this.addOptions(key,value)}
hideSubmitButton={true}
/>

Select item programmatically

Hi, thank for this select plugin, i would like to select one item programmatically, is there any way to do that please

Reduce number of props by grouping styles props into separate config objects

As it is at the moment, the component is highly customisable, but with the way it is set up, adding more options to customise means more props which is becoming too overwhelming. For example:

   <MultiSelect
          hideTags
          items={items}
          uniqueKey="id"
          ref={(component) => { this.multiSelect = component }}
          onSelectedItemsChange={this.onSelectedItemsChange}
          selectedItems={selectedItems}
          selectText="Pick Items"
          searchInputPlaceholderText="Search Items..."
          altFontFamily="ProximaNova-Light"
          tagRemoveIconColor="#CCC"
          tagBorderColor="#CCC"
          tagTextColor="#CCC"
          selectedItemTextColor="#CCC"
          selectedItemIconColor="#CCC"
          itemTextColor="#000"
          searchInputStyle={{ color: '#CCC' }}
          submitButtonColor="#CCC"
          submitButtonText="Submit"
        />

Above is the minimal customisation that can be done.

So the suggestion is to group all related style props into their own config prop object so there wouldn't be need to add more props to component when specific styling is needed. That would easily be added on the fly by user as it will be catered for by the application of such config props. Below is an example of what it might become:

   <MultiSelect
          hideTags
          items={items}
          uniqueKey="id"
          ref={(component) => { this.multiSelect = component }}
          onSelectedItemsChange={this.onSelectedItemsChange}
          selectedItems={selectedItems}
          selectText="Pick Items"
          searchInputPlaceholderText="Search Items..."
          tagItemStyle={{
             // style definition here
          }}
          selectedIconStyle={{
             // style definition here
          }}
          selectedItemStyle={{
             // style definition here
          }}
          itemStyle={{
             // style definition here
          }}
          searchInputStyle={{
              // style definition here
          }}
          submitButtonTextStyle={{
            // style definition here
          }}
          submitButtonText="Submit"
        />

The above example shows how flexible it would be customise lots of things without the need to update the component.

This would introduce a considerable amount of breaking changes and would see a major version bump.

Submit Button is not visible when fixedHeight is true.

Hi @toystars,
Thanks for creating the library. I am trying to use the library on one of my React-native project and found that on multiselect mode (single=false) with fixedHeight enabled, the submit button is missing. Following is the code snippet I am using.

class MultiSelectExample extends Component {
  constructor() {
    super()

    this.state = {
      selectedItems: []
    };

    this.items = [{
      id: '92iijs7yta',
      name: 'Ondo',
    }, {
      id: 'a0s0a8ssbsd',
      name: 'Ogun',
    }, {
      id: '16hbajsabsd',
      name: 'Calabar',
    }, {
      id: 'nahs75a5sg',
      name: 'Lagos',
    }, {
      id: '667atsas',
      name: 'Maiduguri',
    }, {
      id: 'hsyasajs',
      name: 'Anambra',
    }, {
      id: 'djsjudksjd',
      name: 'Benue',
    }, {
      id: 'sdhyaysdj',
      name: 'Kaduna',
    }, {
      id: 'suudydjsjd',
      name: 'Abuja',
    }, {
      id: 'new1',
      name: 'newnew1'
    }, {
      id: 'new2',
      name: 'newnew2'
    }, {
      id: 'new3',
      name: 'newnew3'
    }, {
      id: 'new4',
      name: 'newnew4'
    }, {
      id: 'new5',
      name: 'newnew5'
    }, {
      id: 'new6',
      name: 'newnew6'
    }
    ];
  }

  onSelectedItemsChange = selectedItems => {
    this.setState({ selectedItems });
  };

  render() {
    const { selectedItems } = this.state;
    return (
      <View style={{ flex: 1 }}>
        <MultiSelect
          fixedHeight={true}
          hideTags
          items={this.items}
          uniqueKey="id"
          ref={(component) => { this.multiSelect = component }}
          onSelectedItemsChange={this.onSelectedItemsChange}
          selectedItems={selectedItems}
          selectText="Pick Items"
          searchInputPlaceholderText="Search Items..."
          altFontFamily="ProximaNova-Light"
          tagRemoveIconColor="#CCC"
          tagBorderColor="#CCC"
          tagTextColor="#CCC"
          selectedItemTextColor="#CCC"
          selectedItemIconColor="#CCC"
          itemTextColor="#000"
          searchInputStyle={{ color: '#CCC' }}
          submitButtonColor="#CCC"
          submitButtonText="Submit"
        />
        <Text> Hello World</Text>
      </View>
    );
  }
}

demo

Search Filter not working correctly

Issue summary

When I type a certain keyword on the search bar it also returning items without the keyword on the name

Library versions

react-native: 0.55.4
react-native-multiple-select: ^0.4.4

test

DropDown overlapping error

image uploaded from ios

When fixHeight is set true, the dropdown overlaps with the components behind. The components behind can still be interacted even when the dropdown is open.

How do i fix this?

Change in state does not change default-text (getDefaultValue)

State change does not change the default-text (getDefaultValue) of the input.

<GooglePlacesAutocomplete
        placeholder='Address'
        minLength={2}
        autoFocus={false}
        returnKeyType={'default'}
        fetchDetails={true}
        styles={{
          textInputContainer: {
            backgroundColor: 'rgba(0,0,0,0)',
            borderTopWidth: 0,
            borderBottomWidth: 1,
            borderBottomColor: '#D9D5DC'
          },
          textInput: {
            marginLeft: 0,
            marginRight: 0,
            color: '#000000',
            fontSize: 13,
          },
          predefinedPlacesDescription: {
            color: '#000000'
          },
        }}
        query={{
          // available options: https://developers.google.com/places/web-service/autocomplete
          key: 'AIzaSyBAZBpWYMUskFgPU_LATPHd521AKJ3CEz4',
          language: 'en', // language of the results
          types: 'geocode' // default: 'geocode'
        }}
        placeholderTextColor='#575757'
        onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
          console.log(data, details);
          this.onAddessSelect(data, details);
        }}
        currentLocation={false}
        nearbyPlacesAPI='GooglePlacesSearch'
        getDefaultValue={ () => this.state.address_line_1 ? this.state.address_line_1 + ' ' + 
            this.state.address_line_2 + ' ' + 
            this.state.suburb + ' ' + 
            this.state.city : ''
        } />

Categories and max number of items

Hi,

Thanks for putting together this package! I have 2 questions:

  • Is it possible to specify an items array with categories? Something like:
    Category1
    Item 1
    Item 2
    Category 2
    Item 3
    Category 3
    Item 4
    Item 5
    Item 6

Obviously, the categories should not be made possible to pick.

  • Is it possible to define a maximum number of items that the user can pick from?

Thanks

onChangeInput

onChangeInput not working
<MultiSelect
hideTags
items={[
{
id: "sdhyaysdj",
name: "Kaduna"
},
{
id: "suudydjsjd",
name: "Abuja"
}
]}
uniqueKey="id"
ref={component => {
this.multiSelect = component
}}
onSelectedItemsChange={this.onSelectedItemsChange}
selectedItems={['sdhyaysdj']}
selectText="Select Country"
searchInputPlaceholderText="Search cuontries..."
onChangeInput={text => console.warn(text)}
tagRemoveIconColor="#CCC"
tagBorderColor="#CCC"
tagTextColor="#CCC"
selectedItemTextColor="#CCC"
selectedItemIconColor="#CCC"
itemTextColor="#000"
displayKey="name"
searchInputStyle={{ color: "#CCC",height:60 }}
submitButtonColor="#CCC"
submitButtonText="OK"
/>

App is crashing in release mode - Invalid attempt to spread non-iterable instance

Issue summary

App is crashing in release mode with this component use, its happening after upgrading react-native to 0.56, babel 7

Library versions

react-native: 0.56.0
react-native-multiple-select: 0.4.0

Steps to Reproduce

  1. Select any multi select item in release mode of the app and app crashes.

Expected Behavior

App should not crash

Actual Behavior

App is crashing immediately after selecting an item in multi mode.

Feature Request - Option to hide searchbar

Issue summary

Feature Request

Library versions

react-native: 0.48.1
react-native-multiple-select: 0.4.4

Please provide an API option to hide the search bar. Sometimes it is unnecessary.

Thanks.

Border handling for inner view tag

See the attached image, with selected 1 it is how it displayed when screen renders. But as soon as you select another item, the border is gone.

screenshot_2017-11-08-14-07-43-077_com ruef

screenshot_2017-11-08-14-07-55-193_com ruef

Add props for this border which will help in error handling as well. I have to wrap it in a view tag which shows multiple borders in case of error.

screenshot_2017-11-08-14-19-36-523_com ruef

How to config to Auto open list

Issue summary

I have a screen for select items
So, I want to auto display list when I open this scene.
Some one can help me?
Thank's a lot.

Library versions

Steps to Reproduce

(Write your steps here:)

Expected Behavior

(Write what you thought would happen.)

Actual Behavior

(Write what happened. Add screenshots!)

Reproducible Code

(Paste exact code snippet and instructions to reproduce the issue.)

how to show the selected values on top of others ?

I got like 15 values that are selected or non selected, & the user has to scroll down to find which priorities are selected and which not, Is it possible to display the already selected values on top of non -selected ?

Dropdown input style and selected items text

Issue summary

I have 2 questions:

  1. How to add custom style to dropdown input?
  2. How to change text of selected items? Now its "3 selected"
    Thanks!

Library versions

react-native: 0.55.2
react-native-multiple-select: 0.4.4

How to remove search icon?

Sorry if this is elsewhere. We don't want the search icon (or the search feature) at all. Is there a way to remove it?

Thanks!

Unrecognized font family Material Design Icons

"native-base": "^2.7.1",
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-animatable": "^1.3.0",
"react-native-blur": "^3.2.2",
"react-native-elements": "^0.19.1",
"react-native-image-crop-picker": "^0.20.3",
"react-native-multiple-select": "^0.4.4",
"react-native-snap-carousel": "^3.7.2",
"react-native-ui-lib": "^3.3.165",
"react-native-vector-icons": "^4.6.0",
"react-navigation": "1.5.4"

2018-07-24 1 28 46

How can I fix it~?

Cannot read the property 'getSelectedItemsExt' of undefined

I am building an App and referring this link
i implemented same code for my App, but i am getting error "Cannot read the property 'getSelectedItemsExt' of undefined".
One more error is "submit" button is also not showing up. I have tried all the ways but failed.

import React, { Component } from 'react';
import { AppRegistry, StyleSheet, TextInput, View, ListView, Alert, Button,     Platform, ToastAndroid, TouchableOpacity, ActivityIndicator, Text, Picker, ScrollView }
from 'react-native';
import { StackNavigator } from 'react-navigation';
import MultiSelect from 'react-native-multiple-select';


class manage_publishers extends Component {
static navigationOptions = {
	title: 'Manage Publishers',
};

constructor() {
	super()
	this.state = {
		isLoading: true,
		selectedPublishers1:[],
		publishersByCategory: [],
		publishersByClient: [],
		publishersByGroup: [],
		dataSource:[]
	}
}

componentDidMount() 
{
	const base64 = require('base-64');
	fetch('APIURL'+this.props.navigation.state.params.id, 
	{
		method: 'GET',
		headers: {
			'Accept': 'application/json',
			'Content-Type': 'application/json',
			"Authorization": "Basic " + base64.encode("ABC:XYZ")
		}
	}).then((response) => response.json()
	)
		.then((responseJson) => {
			this.setState({
				categories: responseJson.PublisherByCategory,
			}, function () {
      
		});
	})
	.catch((error) => {
		console.log("error in category");
		console.log(error);
	});


}

onSelectedPublishersByCategoryChange = (publishersByCategory) => {
	console.log(publishersByCategory);
	this.setState({ publishersByCategory });
}



render() {
	const { navigate } = this.props.navigation;
	if (this.state.isLoading) {
	return (
    <View style={{ flex: 1, paddingTop: 20 }}>
      <ActivityIndicator />
    </View>
  );
}
return ([
  <View style={{flex: 1,paddingTop: (Platform.OS === 'ios') ? 20 : 20, padding: 5}}>
    <Text style={{ padding: 5, fontSize: 35, backgroundColor: '#2196F3', marginBottom: 7 }}>
		Manage Publishers
	</Text>
    <MultiSelect
      items={this.state.categories}
      uniqueKey="id"
      ref={(component) => { this.multiSelect = component }}
      onSelectedItemsChange={this.onSelectedPublishersByCategoryChange}
      selectedItems={this.state.publishersByCategory}
      selectText="Publishers by Category"
      searchInputPlaceholderText="Search Publisher..."
      onChangeInput={ (text)=> console.log(text)}
      altFontFamily="ProximaNova-Light"
      tagRemoveIconColor="#CCC"
      tagBorderColor="#CCC"
      tagTextColor="#CCC"
      selectedItemTextColor="#CCC"
      selectedItemIconColor="#CCC"
      itemTextColor="#000"
      displayKey="name"
      searchInputStyle={{ color: '#CCC' }}
      submitButtonColor="#CCC"
      submitButtonText="Submit"
    />
  </View>,
  <View>
     {this.multiSelect.getSelectedItemsExt(selectedItems)} 
  </View>
 ]);
}
}
});

 module.exports = manage_publishers;

Please have a look at this and provide me solution, I'll be very thankful .

List of items not being updated once a new item is added

The MultiSelect component isn't showing items added after the first render.

constructor(props) {
  super(props);

  this.state = {
    items: [{id: 1, name: 'A'}]
  }
}
<MultiSelect
  items={this.state.items}
  ...
/>

List shows item 'A' as expected. but once we add 'B' to the list, it's not showing the new item on the list:

const items = this.state.items;
items.push({ id: 2, name: 'B' });

this.setState({ items });

List still shows 'A', while we expect to see 'A' and 'B'.

Same thing happens to selectedItems.

Would be great to be able to update both lists once we set the new state.

Thanks for the awesome component!

First element is never selected

Issue summary

When you select the first item of the array it isn't marked as selected and is added multiple times to 'selectedItems'

Library versions

react-native: 0.48.0
react-native-multiple-select: ^0.2.7

Steps to Reproduce

  1. Init the component with the example
  2. Select the first option
  3. Option is not marked as selected

Expected Behavior

The first option should be selected or unselected according with selectedItems

Actual Behavior

The first option is never marked as selected and index 0 is added multiple times to selectedItems

Item 0 is selected when the list is collapsed

simulator screen shot - iphone 8 - 2017-12-06 at 16 08 20

But when the list is shown, the item is nor marked as selected

simulator screen shot - iphone 8 - 2017-12-06 at 16 15 05

After clicking multiple times the first item it is repeated on selectedItems

simulator screen shot - iphone 8 - 2017-12-06 at 16 15 35

This component has heavy dependencies

I need to install native-base along with the entirety of underscore.. isn't that a bit much?

This seems to be more of a component built specifically for native-base and not just react-native ?

component ref is not defined

Issue summary

I was testing the sample code from the README abbreviated below:

render() {
   const { selectedItems } = this.state;
   return (
     <View style={{ flex: 1 }}>
        <MultiSelect
          ...
          ref={(component) => { this.multiSelect = component }}
          ...
        />
        <View>
          {this.multiSelect.getSelectedItemsExt(selectedItems)}
        </View>
     </View>
   )
}

I get the following error:

TypeError: Cannot read property 'getSelectedItemsExt' of undefined

ie this.multiSelect is not defined. Is this correct? Don't I have to wait until the next clock edge (ie wrap in a setTimeout) before I can access this.multiSelect?

Library versions

react-native: 0.55.3
react-native-multiple-select: 0.4.4

Module does not exist in the module map

Issue summary

Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Unable to resolve module react-native-multiple-select from /Users/***/Projects/EZJobMatch/src/components/Common/MultiSelectExample.js: Module does not exist in the module map

Library versions

 "react": "16.3.0-alpha.1",
"react-native": "0.54.1",
"react-native-multi-select": "^0.1.1",
"react-native-quick-select": "0.0.4",
"react-native-vector-icons": "^4.5.0"

Steps to Reproduce

(Write your steps here:)

  1. I installed react-native-multiple-select and react-native-vector-icons then linked.
  2. using full code form here "https://www.npmjs.com/package/react-native-multiple-select"
  3. export that and linking form another page

Expected Behavior

It should run nicely . my bad...

(Write what you thought would happen.)

Actual Behavior

If i did any mistake it should show error with line but it is showing "Module does not exist in the module map"
if i remove "import MultiSelect from 'react-native-multiple-select';" error going away .
only asking for "MultiSelect". and without "MultiSelect" app is working fine.

(Write what happened. Add screenshots!)

Reproducible Code

import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
} from 'react-native';
import MultiSelect from 'react-native-multiple-select';

const items = [{
id: '92iijs7yta',
name: 'Ondo',
}, {
id: 'a0s0a8ssbsd',
name: 'Ogun',
}, {
id: '16hbajsabsd',
name: 'Calabar',
}, {
id: 'nahs75a5sg',
name: 'Lagos',
}, {
id: '667atsas',
name: 'Maiduguri',
}, {
id: 'hsyasajs',
name: 'Anambra',
}, {
id: 'djsjudksjd',
name: 'Benue',
}, {
id: 'sdhyaysdj',
name: 'Kaduna',
}, {
id: 'suudydjsjd',
name: 'Abuja',
}];

const onSelectedItemsChange = (selectedItems) => {
// do something with selectedItems
console.log('Selected Items: ', selectedItems);
};

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5FCFF',
padding: 10,
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 30,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});

const MultiSelectExample = () => {
return(


MultiSelect Sample

<MultiSelect
single
items={items}
uniqueKey="id"
onSelectedItemsChange={onSelectedItemsChange}
selectedItems={[]}
selectText="Pick Items"
searchInputPlaceholderText="Search Items..."
tagRemoveIconColor="#CCC"
tagBorderColor="#CCC"
tagTextColor="#CCC"
selectedItemTextColor="#CCC"
selectedItemIconColor="#CCC"
itemTextColor="#000"
searchInputStyle={{ color: '#CCC' }}
submitButtonColor="#CCC"
submitButtonText="Submit"
/>

);
};
export default MultiSelectExample;

Unrecognized font family "Material Design Icons"

Issue summary

Breaking error happens when trying to render the MultiSelect component.
image

I'm not doing anything special and I have latest react-native-vector-icons and the fonts that come with it.

My code is this:

<MultiSelect
                  items={Object.values(myDataObject)}
                  uniqueKey="uri"
                  onSelectedItemsChange={this.onSelectedItemsChange}
                  selectedItems={this.state.selectedItems}
                  searchInputPlaceholderText="Type Item Name..."
                  altFontFamily="System"
                  tagRemoveIconColor="#CCC"
                  tagBorderColor="#CCC"
                  tagTextColor="#CCC"
                  selectedItemTextColor="#CCC"
                  selectedItemIconColor="#CCC"
                  itemTextColor="#000"
                  displayKey="label"
                  searchInputStyle={{color: '#CCC'}}
                />

I tried different fonts in the altFontFamily and tried removing the option alltogether.

Library versions

react-native: 0.53.3
react-native-multiple-select: 0.4.1
react-native-vector-icons: 4.5.0

Steps to Reproduce

  1. Import MultiSelect
  2. Try to render it

Expected Behavior

I expect it to render and work as described.

(Write what you thought would happen.)

Actual Behavior

I get this error
image

I tried rm -rf ios/build and rm -rf node_modules and react-native link
I also cleaned the project and rebuild
The error keeps happening.

Reproducible Code

My code is this:

<MultiSelect
                  items={Object.values(myDataObject)}
                  uniqueKey="id"
                  onSelectedItemsChange={this.onSelectedItemsChange}
                  selectedItems={this.state.selectedItems}
                  searchInputPlaceholderText="Type Item Name..."
                  altFontFamily="System"
                  tagRemoveIconColor="#CCC"
                  tagBorderColor="#CCC"
                  tagTextColor="#CCC"
                  selectedItemTextColor="#CCC"
                  selectedItemIconColor="#CCC"
                  itemTextColor="#000"
                  displayKey="label"
                  searchInputStyle={{color: '#CCC'}}
                />

I tried different fonts in the altFontFamily and tried removing the option alltogether.

Unable to search

softkeyboard not opening event after on tapping of search inputbox

<MultiSelect
   items={props.items}
   uniqueKey="id"
   onSelectedItemsChange={props.onSelectedItemsChange}
   fixedHeight={true}
   selectedItems={props.selectedItems}
   hideSubmitButton = {false}
                           
 />

ParseError: 'import' and 'export' may appear only with 'sourceType: module'

Hi I'm having an error when run babelify.

This is the command:

browserify -t [ babelify --presets [ es2015 es2016 react ] ] app/main.js -o app/bundle.js

and this is the error:

/my-project/node_modules/react-native-multiple-select/index.js:6
import MultiSelect from './lib/react-native-multi-select';
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'

Can someone help me?

How to mark selected Items in DropDown

Issue summary

I have been selecting multiple options but options are not marked so how a user can know that a particular option is already selected.

Library versions

multipalselectissue

Steps to Reproduce

(Write your steps here:)

Expected Behavior

(Write what you thought would happen.)

Actual Behavior

(Write what happened. Add screenshots!)

Reproducible Code

(Paste exact code snippet and instructions to reproduce the issue.)

Add support to override templates for "No item to display." and "Add {item.name} (tap or press return)" with custom user messages.

Issue summary

Add support to override templates for "No item to display." and "Add {item.name} (tap or press return)" with custom user messages.

Library versions

react-native: 0.53.0
react-native-multiple-select: 0.4.1

Steps to Reproduce

  1. Pass empty array in selectedItems

  2. See "No item to display." message.

  3. Set canAddItem to true

  4. See "Add {item.name} (tap or press return)" message while editing text.

Expected Behavior

We should be able to pass our own template or somehow override this message.

Actual Behavior

This support is not there.

Component Getting invisible

Using
"react-native-multiple-select": "^0.2.1",
"react-native-vector-icons": "^4.2.0",

everything is working fine except when item is selected and submit is clicked, whole MultiSelect component gets invisible instead of showing selected items.

unable to change multiselect background color

hi, i'm trying to change the background color for the drop down item, there's no record of if on the attribute list.
here's my code:

<MultiSelect style={{flex: 1,backgroundColor:"#000"}}
        items={items}
        uniqueKey="id"
        onSelectedItemsChange={selectedItem => {
          return changeCallback(selectedItem);
        }}
        style={{backgroundColor:"#000"}}
        selectedItems={condition.value}
        selectText={condition.message}
        searchInputPlaceholderText="Search Items..."
        altFontFamily="ProximaNova-Light"
        tagRemoveIconColor="#CCC"
        tagBorderColor="#CCC"
        tagTextColor="#CCC"
        selectedItemTextColor="#CCC"
        selectedItemIconColor="#CCC"
        itemTextColor="#000"
        searchInputStyle={{ color: '#CCC' }}
        submitButtonColor="#CCC"
        submitButtonText="Select" />

thanks a lot.

Set a custom width to selected elements

Issue summary

How set a custom width to selected list, when the text is long, , it's actually go out of screen

Library versions

react-native: 0.56.0
react-native-multiple-select: 0.4.4

Steps to Reproduce

1.Have list of items with text long
2.Select one or more items

Expected Behavior

The text of selected items see completed and the remove icon too

screen shot 2018-10-12 at 9 19 49 am
screen shot 2018-10-12 at 9 20 25 am

Label and Button not showing

When I started to select I have this issue seen on the attached photo. Sometimes it looks good and then I get the issue again. Is anyone having same issue?

capture _2017-11-29-11-54-12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.