Git Product home page Git Product logo

onmotion / react-native-autocomplete-dropdown Goto Github PK

View Code? Open in Web Editor NEW
183.0 183.0 73.0 5.72 MB

Dropdown Item picker with search and autocomplete (typeahead) functionality for react native

License: MIT License

JavaScript 4.66% Objective-C 3.17% Ruby 3.02% Objective-C++ 1.13% TypeScript 84.44% Kotlin 3.59%
android autocomplete autocomplete-suggestions dropdown dropdown-menu hacktoberfest ios react-native select typeahead

react-native-autocomplete-dropdown's People

Contributors

abpbackup avatar brion-bitzen avatar captainhaider avatar davichostar avatar drastus avatar dravec avatar gabriel1lima avatar joshsj89 avatar lucassaid avatar marcelinaziolkiewicz avatar mmomtchev avatar nholik avatar onmotion avatar paitoanderson avatar soleh45 avatar spmorr01 avatar thibaultcapelli avatar viacovne avatar villar74 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

react-native-autocomplete-dropdown's Issues

Issue wrapping with scrollview

I tried to wrap the autocomplete to scrollview but i got this error.

VirtualizedLists should never be nested inside plain ScrollViews with the same orientation because it can break windowing and other functionality - use another VirtualizedList-backed container instead

Any way to use a render a custom Text Input

Been looking for a react native autocomplete library and they all seem to have issues with certain conditions and functionality that I need. However react-native-autocomplete-dropdown seems to work really nicely and tick all the boxes...except that I am trying to align the look of the input with Text Input from react-native-paper.

With other dropdown/autocomplete libraries, there is usually the option to have a custom component for rendering the input, but this doesn't seem to be possible with this library? Any way to do this, or do I need to manually work up the styles as best I can to match? The issue with styling approach is it is quite difficult to match everything up, especially the floating labels/placeholder that you get with paper.

Don't show suggestionList until some text is written

How can I hide the suggestionList if the input text length is < than 3 for example.

I already try using onFocus prop with the useRef like this

const handleOnFocus = () => {
    dropdownController.current?.close();
 };

but it didn't work

SuggestionList inside a Modal is transparent and could not be selected in iOS

I am facing an issue similar to the one mentioned in the /issues/16 in my iOS. This works as expected in Android.

The difference to the above mentioned issue is, here the dropdown is present inside a KeyboardAwareScrollView which is inturn present inside a Modal. I have tried React.Fragment for parent View and tried zIndex as well. But nothing seems to be helping. Or may be im applying it wrong. Please let me know if any further details needed to explain the issue.

Screenshot 2022-05-13 at 10 05 54 PM

Clear the textInput Programatically

First of All Thank you for the wonderful library. I would like to clear the input programatically instead of clear button. can u please suggest me something to implement like this.

How to Change the color of the placeholder text??

Hello everyone is there any way to change the color of the placeholder?

Code:

<AutocompleteDropdown
        clearOnFocus={false}
        closeOnBlur={false}
        closeOnSubmit={false}
        showClear={false}
        initialValue={{ id: '1' }} 
        inputContainerStyle={styles.inputContainerStyle}
        textInputProps={{
          placeholder: 'select item',
          style: {
            fontSize: 20,
          },
        }}
        suggestionsListMaxHeight={Dimensions.get('window').height * 0.5}
        dataSet={dataSet}
      />

Using renderItem cannot autocomplete strings

When not using renderItem, It can autocomplete text strings. But on using renderItem, component cannot autocomplete strings.

In example RemoteDataExample (not using renderItem)
image

In example RemoteDataExample3 (using renderItem), you can see the difference between dropbox.
image

Very nice autocomplete-dropdown library! please fix this issue....

Sometimes list items appear blank

I've implemented a simple autocomplete box driven by a local dataset. I memoize the list without dependencies, and the behavior of the search results seems inconsistent. In the video I've attached, you can see me trying to search for Artist, which appears sometimes and not others, but I've confirmed that the blank row is still connected to the right list item (i.e., when I click on it, it does respond as I expect).

I can't figure out what makes it show or not, since you can see in the video that I do ultimately make it appear by just typing and backspacing a few times, selecting other items, etc. It doesn't appear to be related to which item is currently selected.

Screen.Recording.2021-08-24.at.6.45.45.PM.mov

I'm a fan of how good the default styling is out of the box, so I'd love to make this work. Do you have any ideas?

I don't currently have time to make a fully reproducible demo, but the component is quiet simple:

import React, { useState, useContext, useMemo } from 'react';
import { View } from 'react-native';
import { AutocompleteDropdown } from 'react-native-autocomplete-dropdown'

import DecksContext from 'CONTEXTS/decks';
import Card from './Card';

export default function CardFinder() {
  const { ownedCards } = useContext(DecksContext);

  const cardsList = useMemo(() => {
    return ownedCards.map(card => ({ id: card.card_id, title: card.title }));
  }, []);

  const [ cardId, setCardId ] = useState(null);

  return (
    <View>
      <AutocompleteDropdown
        onSelectItem={({ id }) => setCardId(id)}
        dataSet={cardsList}
      />
      {cardId ? (
        <Card id={cardId} />
      ) : null}
    </View>
  );
}

Version info:

"expo": "~42.0.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
"react-native-autocomplete-dropdown": "^1.1.4",

textInputProps shows as invalid prop in ESLint

When using typescript, the linter, or whatever checks the intrinsic props, shows an error saying that the textInputProps is an invalid prop, however if I run the react native app, it works!

Screen Shot 2021-06-18 at 3 45 11 PM

Loading Indicator doesn't animate

I've found that when I set the loading prop to true the loading spinner appears, but it doesn't animate - it doesn't really convey the same message that it's loading when it's stationary.

Bug

zIndex not set correclty

Hi, in your web example, the dropdown is hidden behind other components that are below it in the DOM hirarchy. Are you aware of this issue ?

image

ERROR VirtualizedLists should never be nested inside plain ScrollViews with the same orientation because it can break windowing and other functionality - use another VirtualizedList-backed container instead.

While focus the input it triggers the below error.

ERROR VirtualizedLists should never be nested inside plain ScrollViews with the same orientation because it can break windowing and other functionality - use another VirtualizedList-backed container instead.

Here is my code.
<KeyboardAwareScrollView keyboardShouldPersistTaps='always' enableOnAndroid={true} contentContainerStyle={{ flexGrow: 1 }}>
<AutoCompleteInput
name='cityId'
dataSet={cities}
placeholder='City'
disabled={!(isCityDisable || cities.length <= 0)}
titleKey='cityName'
titleId='cityId'
closeOnBlur={true}
emptyResultText='No city found'
/>

There is Error When open the Dropdown

ERROR VirtualizedLists should never be nested inside plain ScrollViews with the same orientation because it can break windowing and other functionality - use another VirtualizedList-backed container instead.

Section List Implmentation

i have a data list like this ```
"data": {
"hotels": [
{
"id": "happiness_guesthouse",
"name": "Happiness Guesthouse",
"region_id": 6056164
},
{
"id": "478_msl_pak_chong",
"name": "478 MSL. Pak Chong",
"region_id": 6056164
},
{
"id": "the_pino_hotel_pakchong",
"name": "The Pino Hotel Pak-Chong",
"region_id": 6056164
},
{
"id": "baanthai_norway_pak_chong",
"name": "BaanThai Norway Pak Chong",
"region_id": 6056164
},
{
"id": "rachamanee_resort",
"name": "Rachamanee Resort",
"region_id": 6056164
}
],
"regions": [
{
"id": 6056164,
"name": "Pak Chong",
"type": "City",
"country_code": "TH"
},
{
"id": 6159488,
"name": "Le Paquier",
"type": "City",
"country_code": "CH"
},
{
"id": 6304681,
"name": "Pak Khlong",
"type": "City",
"country_code": "TH"
},
{
"id": 6307227,
"name": "Pak Tako",
"type": "City",
"country_code": "TH"
}
]
}



the best solution for this is section list. i have try but there were multiple. 

any solution for this

Unable to use storybook with this component

We are using Storybook in our project to document the components we created for the app. After we installed this library storybook stopped working in the app.

Below is our App.tsx file, for some reason the fonts are never loaded and it stays forever on the AppLoading component. Both true and false values for renderDoc end up loading forever.

import React from 'react';

import { useFonts } from 'expo-font';
import { Inter_400Regular, Inter_600SemiBold } from '@expo-google-fonts/inter';

import AppLoading from 'expo-app-loading';
import { ThemeProvider } from 'styled-components';
import { appTheme } from './src/styles/theme';

import { StatusBar } from './src/components';
import { Routes } from './src/routes';
import Storybook from './storybook';

const renderDoc = false;

const App = () => {
  const [fontsLoaded] = useFonts({
    Inter_400Regular,
    Inter_600SemiBold,
  });

  if (!fontsLoaded) {
    return <AppLoading />;
  }

  return (
    <ThemeProvider theme={appTheme}>
      {renderDoc ? (
        <Storybook />
      ) : (
        <>
          <StatusBar />
          <Routes />
        </>
      )}
    </ThemeProvider>
  );
};

export default App;

If we change it to this code below then it works to at least run the app.

return (
    <ThemeProvider theme={appTheme}>
          <StatusBar />
          <Routes />
    </ThemeProvider>
  );

If we keep the Storybook code and remove the loading verification then storybook runs but none of the components work because of an error with font loading.

Simulator Screen Shot - iPhone 11 - 2021-09-02 at 21 53 39

Add missing TS types

There are still some missing types in index.d.ts that cause TypeScript errors:

  1. renderItem function can return undefined – it's useful for filtering options
  2. ItemSeparatorComponent is completely missing, it can be passed as a prop to change options separator or (when false) to remove it completely.

Not able to remove the border line in dropdown items

Hello everyone I need to remove border line of the dropdown items.
Even try using the renderItem to create new list items of drop down. But I can't find any way to remove the dropdown list border.

Please see the example below:

Screen Shot 2022-10-11 at 13 09 06

Code:

import React, { useState } from 'react';
import { AutocompleteDropdown } from 'react-native-autocomplete-dropdown';
import Icon from 'react-native-vector-icons/MaterialIcons';
import { styles } from './styles/autocomplete.styles';
import { Text } from 'native-base';
import { Dimensions, Platform } from 'react-native';

export function AlAutoComplete() {
const [selectedItem, setSelectedItem] = useState();
const dataset = [
{ id: '1', title: 'Alpha' },
{ id: '2', title: 'Beta' },
{ id: '3', title: 'Gamma' },
{ id: '4', title: 'Gamma' },
{ id: '5', title: 'Gamma' },
{ id: '6', title: 'Alpha' },
{ id: '7', title: 'Alpha' },
{ id: '8', title: 'Alpha' },
{ id: '9', title: 'Alpha' },
{ id: '10', title: 'Gamma' },
{ id: '11', title: 'Gamma' },
{ id: '12', title: 'Gamma' },
{ id: '13', title: 'Gamma' },
{ id: '14', title: 'Gamma' },
{ id: '15', title: 'Gamma' },
];

return (
<AutocompleteDropdown
clearOnFocus={false}
closeOnBlur={false}
closeOnSubmit={false}
showClear={false}
initialValue={{ id: '1' }}
onSelectItem={setSelectedItem}
inputContainerStyle={styles.inputContainerStyle}
suggestionsListMaxHeight={Dimensions.get('window').height * 0.5}
dataSet={dataset}
/>
);
}

export default AutoComplete;

onChangeItem

Is there no #onchangeitem option in َAutocompleteDropdown?
Help if you can
Thanks

Nested scrollView

I'm facing some issues when using this component inside a parent scrollView. Basically I can't scroll and also the keyboardAvoidView doesn't work too.

Bug: Unable to select Dropdown items on Android

I'm getting an issue on Android where while the dropdown appears, I can't interact with the dropdown selections at all. It seems to occur whenever I wrap the control in a <View> and apply any styling to that view.

Here is a snack to demonstrate the issue https://snack.expo.dev/@ipwright83/react-native-autocomplete-dropdown. Running on Android you're unable to interact with the dropdown (unless you comment out borderColor and borderWidth) on lines 53-54.

This only seems to affect Android, it works correctly on iOS.

Here's some code to reproduce:

import React, { Node, useState } from 'react';
import {
  Platform,
  SafeAreaView,
  ScrollView,
  StyleSheet,
  Text,
  useColorScheme,
  View,
} from 'react-native';
import { Colors } from 'react-native/Libraries/NewAppScreen';
import { AutocompleteDropdown } from 'react-native-autocomplete-dropdown';

const App: () => Node = () => {
  const styles = getStyles();
  const [selectedItem, setSelectedItem] = useState(null);

  return (
    <React.Fragment>
      <View style={styles.spacer} />
      <View style={styles.container}>
        <AutocompleteDropdown
          clearOnFocus={false}
          closeOnBlur={true}
          initialValue={{ id: '2' }} // or just '2'
          dataSet={[
            { id: '1', title: 'Alpha' },
            { id: '2', title: 'Beta' },
            { id: '3', title: 'Gamma' },
          ]}
        />
        <Text style={{ color: '#668', fontSize: 13 }}>
          Selected item: {JSON.stringify(selectedItem)}
        </Text>
      </View>
    </React.Fragment>
  );
};

const getStyles = () => ({
  spacer: {
    height: 50,
  },
  container: {
    borderColor: "red",
    borderWidth: 1,
  }
});

export default App;

Suggestion Text Not Visibile

For some reason, the suggestion text is not visible. Here is the code:

<AutocompleteDropdown
                initialValue={{ id: '2' }} // or just '2'
                
                inputContainerStyle={{
                  backgroundColor: 'transparent',
                  marginLeft: 3,
                  maxWidth: 166,
                  height: 20,
                  marginTop: -15,
                  zIndex: 10,
                }}
                suggestionsListContainerStyle={{
                  
                  marginTop: -30,
                  marginLeft: 10,
                  width: 231,
                  height: 135,
                  zIndex: 20,
                }}
                clearOnFocus={false}
                closeOnBlur={true}
                textInputProps={{
                  placeholder: 'Enter Exercise',
                  style: {
                    color: 'white',
                    fontWeight: 'bold',
                  },
                  placeholderTextColor: 'white',
                }} // or just '2'
                ItemSeparatorComponent={<View style={{ height: 0 }} />}

                suggestionsListTextStyle={{ color: 'black' }}
                suggestionsListMaxHeight={135}
                onOpenSuggestionsList={() => {
                  suggestionOpened();
                }}
                onSelectItem={item => {
                  item && changePic(item.pic);
                  setSearching(false);
                }}
                onChangeText={item => {
                  item && getData(item);
                }}
                showClear={false}
                dataSet={dataSet}
              />

Screenshot:

image

Prevent open on focus

Is there a way to prevent the dropdown from opening onFocus? I need it to only open when the user enters a search term.

Unable to scroll on Android

Hi, I found this addon a few days ago and I've been using it in my project, but for some reason the suggestions list is not scrollable for me when using android (works fine for ios though). I've tried a lot of things that have worked for others but so far none of them has worked for me. Is there a fix for this? Thanks in advance.

closeOnBlur causing issues in Web version

I'm not really sure if you're supporting this for web, but I've had pretty good luck with it the only issue seems to be when I set closeOnBlur to true, the actual value never gets set when you select it from the dropdown. Weirdly it does work if you select it by clicking on the chevron to initiate the dropdown.

Showing Multiple Drop Down

Hi,
First Thanks for this Amazing Package works great

But May i know how can i show 2 DropDown

My Code

<View style={{flex:1}}>
      <DropDown />
       <DropDown />
</View>

Help -> Avoid 2 press actions to select item from dropdown

Hi, as i see at the moment, we need to press twice to select item and close the dropdown. I guess this happens because we are focused in the input. Is there a way to avoid this, and select the item and close dropdown from 1 press?

How to setup the value?

I'm not talking about initial value, I'm talking about how to manually set the value in the search bar? Like how can I change the text in the search bar based on the state, but not onSelect or onChangeText?

Feature Request: onClose closure

Hi! Thank you so much for creating this package, I am really enjoying it and it works really well.

I thought it would be nice to have a onClose/onBlur prop that receives a function that runs whenever the focus goes to another component, or when the user is done with the input.

Suggestion List not scrolling.

Hello,

I implemented the following code, but my suggestion list is not scrolling. What could be wrong?

<AutocompleteDropdown
debounce={600}
emptyResultText={'Nenhum item encontrado.'}
clearOnFocus={true}
closeOnBlur={true}
closeOnSubmit={false}
useFilter={false}
showChevron={false}
loading={loading}
dataSet={clientesList}
onChangeText={handleOnChangeText}
onClear={handleOnClearPress}
onSelectItem={item => {
item && setSelectedItem(item.id);
}}
renderItem={(item, text) => (
<Text style={{padding: 15}}>{item.title}
)}
inputHeight={45}
suggestionsListMaxHeight={Dimensions.get('window').height * 0.4}
textInputProps={{
placeholder: 'Digite 3 caracteres ou mais...',
autoCorrect: false,
autoCapitalize: 'none',
style: {
borderRadius: 15,
backgroundColor: theme.gray[100],
color: theme.gray[500],
paddingLeft: 10,
},
}}
inputContainerStyle={{
backgroundColor: theme.gray[100],
borderRadius: 15,
}}
/>

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.