Skip to content

Commit e27af1b

Browse files
authored
Picker - Fix wrong offset when items change from search (#3493)
* Refactor PickerItemsList to merge listProps styles using useMemo
1 parent a647cbb commit e27af1b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/components/picker/PickerItemsList.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import React, {useCallback, useContext, useState} from 'react';
2+
import React, {useCallback, useContext, useMemo, useState} from 'react';
33
import {StyleSheet, FlatList, TextInput, ListRenderItemInfo, ActivityIndicator} from 'react-native';
44
import {Typography, Colors} from '../../style';
55
import Assets from '../../assets';
@@ -80,6 +80,13 @@ const PickerItemsList = (props: PickerItemsListProps) => {
8080
return <PickerItem {...item}/>;
8181
}, []);
8282

83+
const _listProps = useMemo(() => {
84+
return {
85+
...listProps,
86+
style: [styles.list, listProps?.style]
87+
};
88+
}, [listProps]);
89+
8390
const renderList = () => {
8491
if (items) {
8592
return (
@@ -88,7 +95,7 @@ const PickerItemsList = (props: PickerItemsListProps) => {
8895
data={items}
8996
renderItem={renderPropItems}
9097
keyExtractor={keyExtractor}
91-
{...listProps}
98+
{..._listProps}
9299
/>
93100
);
94101
}
@@ -99,7 +106,7 @@ const PickerItemsList = (props: PickerItemsListProps) => {
99106
renderItem={renderItem}
100107
keyExtractor={keyExtractor}
101108
testID={`${testID}.list`}
102-
{...listProps}
109+
{..._listProps}
103110
/>
104111
);
105112
};
@@ -204,6 +211,9 @@ const styles = StyleSheet.create({
204211
paddingRight: 16,
205212
flex: 1,
206213
...Typography.text70
214+
},
215+
list: {
216+
height: '100%'
207217
}
208218
});
209219

0 commit comments

Comments
 (0)