Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ yarn add react-native-element-dropdown
| itemTestIDField | String | No | Add this field to the input data. Ex: DATA = [{itemTestIDField: '', label: '', value:: ''}]|
| accessibilityLabel | String | No | Set an accessibilityLabel on the view, so that people who use VoiceOver know what element they have selected |
| itemAccessibilityLabelField | String | No | Add this field to the input data. Ex: DATA = [{itemAccessibilityLabelField: '', label: '', value:: ''}]|
|------|------|------|------|
| selectedToTop | Boolean | No | Put selected items on top of the list |
|------|------|------|------|



Expand Down
9 changes: 8 additions & 1 deletion src/components/MultiSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const MultiSelectComponent: <T>(
itemAccessibilityLabelField,
visibleSelectedItem = true,
mode = 'default',
selectedToTop = false,
} = props;

const ref = useRef<View>(null);
Expand Down Expand Up @@ -519,7 +520,13 @@ const MultiSelectComponent: <T>(
accessibilityLabel={accessibilityLabel + ' flatlist'}
{...flatListProps}
keyboardShouldPersistTaps="handled"
data={listData}
data={
selectedToTop
? listData
.filter((item) => checkSelected(item))
.concat(listData.filter((item) => !checkSelected(item)))
: listData
}
inverted={isTopPosition ? inverted : false}
renderItem={_renderItem}
keyExtractor={(_item, index) => index.toString()}
Expand Down
1 change: 1 addition & 0 deletions src/components/MultiSelect/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface MultiSelectProps<T> {
iconColor?: string;
activeColor?: string;
data: T[];
selectedToTop?: boolean;
value?: string[] | null | undefined;
placeholder?: string;
labelField: keyof T;
Expand Down