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

How to make list go over all other elements vs pushing them down? #19

Closed
ShayanJavadi opened this issue Oct 8, 2018 · 12 comments
Closed

Comments

@ShayanJavadi
Copy link

Currently this is what happens when you trigger the list to show up. It will push everything down. I want the list to go over the other elements and not push the ui around. is this possible?

I was looking at your code and I'm thinking maybe you can add a prop for this and when it's true the map inside _renderItems can send the index to _getRow and after that you'd do something like: renderRow(id, () => this._selectItem(id), items.entities.item[id], listRowStyle, { position: "absolute", top: ROW_HEIGHT * (index + 1))

Here's how the interaction is at the moment:
screen shot 2018-10-08 at 10 12 47 am
screen shot 2018-10-08 at 10 12 42 am

@raynor85
Copy link
Owner

raynor85 commented Oct 9, 2018

Have you tried to specify listStyle prop with position: 'absolute'?

@ShayanJavadi
Copy link
Author

ShayanJavadi commented Oct 10, 2018

@raynor85 Yes. Didn't work. It causes issues with the zIndex. even if you set the zIndex to max it'll still be under everything for some reason.

@ShayanJavadi
Copy link
Author

@raynor85 any updates regarding this?

@raynor85
Copy link
Owner

raynor85 commented Oct 14, 2018

You cannot achieve the desired solution with CSS zIndex, as zIndex is only relative to the parent element. So if you have parents A and B with respective children a and b, b's zIndex is only relative to other children of B and a's zIndex is only relative to other children of A.
If you put zIndex on containerStyle though, you can achieve that since the whole component can be a sibling of other elements. The only problem is that you need to set position: "absolute" to listStyle, and specify a fixed value for the top property, but it doesn't work since the height of the input box is dynamic. An easy solution to achieve that would be wrapping the list into a View component. I will create a PR in less than one hour to solve this issue

@raynor85
Copy link
Owner

This should solve the issue d7044e0
Just follow the practical tip in the FAQ: https://github.com/raynor85/react-native-material-selectize#how-to-make-list-go-over-all-other-elements-vs-pushing-them-down
Thank you for helping to improve this library. Let me know if you can achieve the desired result, so I can close the issue

@ShayanJavadi
Copy link
Author

@raynor85 Awesome! I'll check it out tonight.

@ShayanJavadi
Copy link
Author

@raynor85 Still didn't work for me. Same thing as last time I tried adding position absolute happens.

screen shot 2018-10-14 at 6 07 32 pm

screen shot 2018-10-14 at 6 07 36 pm

Here's my code:

import React from "react";
import { Selectize as Input } from "react-native-material-selectize";
import { Chip } from "react-native-paper";
import { styles, accent } from "./styles";

const {
  containerStyle,
  listRowStyle,
  chipStyle,
} = styles;

const ChipTextInput = (props) => (
  <Input
    {...props}
    textInputProps={{ style: { paddingHorizontal: 15 } }}
    containerStyle={[containerStyle, { zIndex: 9999 }]}
    listRowStyle={listRowStyle}
    tintColor={accent}
    listStyle={{ position: 'absolute' }}
    renderChip={(id, onClose, item) => (
      <Chip onClose={onClose} style={chipStyle}>{item.name}</Chip>
    )}
  />
);

export default ChipTextInput;

styles.js

import { StyleSheet } from "react-native";
import theme from "src/common/styles/theme";

export const { accent } = theme.colors;

export const styles = StyleSheet.create({
  textinputStyle: {
    paddingHorizontal: 15,
  },
  containerStyle: {
    paddingBottom: 0,
    paddingTop: 5,
    backgroundColor: "#F3F3F3",
    borderTopLeftRadius: 4,
    borderTopRightRadius: 4,
    width: "100%",
  },
  listRowStyle: {
    backgroundColor: "#f3f3f3",
  },
  chipStyle: {
    marginLeft: 5,
    marginBottom: 5,
    backgroundColor: "#ddd",
  }
});

@raynor85
Copy link
Owner

raynor85 commented Oct 14, 2018 via email

@ShayanJavadi
Copy link
Author

ShayanJavadi commented Oct 15, 2018

@raynor85 yes I have done that

@raynor85
Copy link
Owner

Your code seems correct. Check out this branch https://github.com/raynor85/react-native-material-selectize/tree/email-validator-absolute-list, go to examples/EmailValidator and run it, you should see the example working as shown:

oct-15-2018 02-05-17

@raynor85
Copy link
Owner

Closing for now, feel free to reopen if it is not solved

@raynor85
Copy link
Owner

@ShayanJavadi have you tried? I think I didn't publish the latest version on npm, sorry about that

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

2 participants