Skip to content

Add widthSelectedItems prop #82

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/react-native-multi-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export default class MultiSelect extends Component {
canAddItems: PropTypes.bool,
onAddItem: PropTypes.func,
onChangeInput: PropTypes.func,
displayKey: PropTypes.string
displayKey: PropTypes.string,
widthSelectedItems: PropTypes.string
};

static defaultProps = {
Expand Down Expand Up @@ -87,7 +88,8 @@ export default class MultiSelect extends Component {
onChangeInput: () => {},
displayKey: 'name',
canAddItems: false,
onAddItem: () => {}
onAddItem: () => {},
widthSelectedItems: null
};

constructor(props) {
Expand Down Expand Up @@ -147,7 +149,8 @@ export default class MultiSelect extends Component {
uniqueKey,
tagTextColor,
selectedItems,
displayKey
displayKey,
widthSelectedItems
} = this.props;
const actualSelectedItems = optionalSelctedItems || selectedItems;
return actualSelectedItems.map(singleSelectedItem => {
Expand All @@ -158,11 +161,11 @@ export default class MultiSelect extends Component {
style={[
styles.selectedItem,
{
width: item[displayKey].length * 8 + 60,
justifyContent: 'center',
height: 40,
borderColor: tagBorderColor
}
},
widthSelectedItems ? {width: widthSelectedItems} : {width: item[displayKey].length * 8 + 60}
]}
key={item[uniqueKey]}
>
Expand Down