Skip to content

Commit

Permalink
Picker - Fix wrong offset when items change from search (#3493)
Browse files Browse the repository at this point in the history
* Refactor PickerItemsList to merge listProps styles using useMemo
  • Loading branch information
nitzanyiz authored Jan 30, 2025
1 parent a647cbb commit e27af1b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/components/picker/PickerItemsList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import React, {useCallback, useContext, useState} from 'react';
import React, {useCallback, useContext, useMemo, useState} from 'react';
import {StyleSheet, FlatList, TextInput, ListRenderItemInfo, ActivityIndicator} from 'react-native';
import {Typography, Colors} from '../../style';
import Assets from '../../assets';
Expand Down Expand Up @@ -80,6 +80,13 @@ const PickerItemsList = (props: PickerItemsListProps) => {
return <PickerItem {...item}/>;
}, []);

const _listProps = useMemo(() => {
return {
...listProps,
style: [styles.list, listProps?.style]
};
}, [listProps]);

const renderList = () => {
if (items) {
return (
Expand All @@ -88,7 +95,7 @@ const PickerItemsList = (props: PickerItemsListProps) => {
data={items}
renderItem={renderPropItems}
keyExtractor={keyExtractor}
{...listProps}
{..._listProps}
/>
);
}
Expand All @@ -99,7 +106,7 @@ const PickerItemsList = (props: PickerItemsListProps) => {
renderItem={renderItem}
keyExtractor={keyExtractor}
testID={`${testID}.list`}
{...listProps}
{..._listProps}
/>
);
};
Expand Down Expand Up @@ -204,6 +211,9 @@ const styles = StyleSheet.create({
paddingRight: 16,
flex: 1,
...Typography.text70
},
list: {
height: '100%'
}
});

Expand Down

0 comments on commit e27af1b

Please sign in to comment.