Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search box keeps shifting infinity to right when inside a view with the following styles #45

Open
ghost opened this issue Dec 11, 2017 · 8 comments

Comments

@ghost
Copy link

ghost commented Dec 11, 2017

This is my view:

  <View style={styles.containerStyle}>
      <Text> Hello </Text>
      <Search
        placeholder={placeholder}
        backgroundColor="#f8fdff"
        borderColor="#ffffff"
      />
    </View>

with the following styles:

const styles = {
  containerStyle: {
    height: 40,
    flex: 1,
    flexDirection: 'row',
    alignItems: 'center'
  }
};

What I want is for a text label to be next to the search box. However, the search box keeps shifting infinity to the right of the screen (at one point the place holder also disappears to the right). I am thinking it has something to do with flexDirection: row . However I do not understand this behavior. What is going wrong?

Also, how to I alight the placeholder (by default its aligning to the right for me?)

Thank you

@sujitpk-perennial
Copy link

I am also facing same issue.

@sujitpk-perennial
Copy link

@aelallam have you found any solution?

@ghost
Copy link
Author

ghost commented Jan 10, 2018

I didn't really come back to this, however, are you placing this view inside a parent view? The problem is due to the styling of the parent view. However if this is the only view you have (the one in my question) then it works okay.

@sujitpk-perennial
Copy link

@aelallam Yes I have added into another view. I think I need to look for another library.

@lichenglu
Copy link

lichenglu commented Jan 28, 2018

@aelallam @sujitpk-perennial. I was having the same issue today. My workaround was to set a width for the searchBar's container, which the package did not expose. However, you could fork the repo and modify it yourself. Or you could use my fork, which exposes a prop containerStyle:

npm i -S git+https://github.com/lichenglu/react-native-search-box

@lacombar
Copy link

Digging in the code, the logic behind onLayout() is broken, killing that code seem to provide a fully working search box, without any kind of fallout.

@FRizzonelli
Copy link

FRizzonelli commented Jun 11, 2018

@lacombar Can you send a PR?

@anhtuank7c
Copy link
Contributor

I will fix within today Mr. Sir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants