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
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ describe('SortableGridlist', () => {
expect(onOrderChange).toHaveBeenCalledWith(newOrder.map(index => TEST_DATA[index]),
newOrder.map(index => TEST_DATA[index].id));
});
it('should forward ScrollView props to the inner ScrollView', () => {
const {getByTestId} = render(<TestCase scrollEnabled={false} showsVerticalScrollIndicator={false}/>);
const scrollView = getByTestId(testID);
expect(scrollView.props.scrollEnabled).toBe(false);
expect(scrollView.props.showsVerticalScrollIndicator).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,28 @@ function generateItemsOrder(data: SortableGridListProps['data']) {
return _.map(data, item => item.id);
}

const CONSUMED_PROPS = [
'renderItem',
'onOrderChange',
'flexMigration',
'orderByIndex',
'data',
'extraData',
// Consumed by useGridLayout — re-applied via listStyle / listContentStyle / listColumnWrapperStyle.
'style',
'contentContainerStyle',
'columnWrapperStyle',
'numColumns',
'itemSpacing',
'maxItemWidth',
'listPadding',
'keepItemSize',
'containerWidth'
];

function SortableGridList<T = any>(props: SortableGridListProps<T>) {
const {renderItem, onOrderChange, flexMigration, orderByIndex = false, ...others} = props;
const {renderItem, onOrderChange, flexMigration, orderByIndex = false, data} = props;
const scrollViewProps = _.omit(props, CONSUMED_PROPS);

const {
itemContainerStyle,
Expand All @@ -28,7 +48,6 @@ function SortableGridList<T = any>(props: SortableGridListProps<T>) {
listContentStyle,
listColumnWrapperStyle
} = useGridLayout(props);
const {data} = others;
const itemsOrder = useSharedValue<ItemsOrder>(generateItemsOrder(data));

// TODO: Remove once flexMigration migration is completed
Expand Down Expand Up @@ -79,6 +98,7 @@ function SortableGridList<T = any>(props: SortableGridListProps<T>) {
return (
<GestureHandlerRootView style={flexMigration ? styles.container : undefined}>
<ScrollView
{...scrollViewProps}
style={listStyle}
contentContainerStyle={[styles.listContent, listContentStyle, listColumnWrapperStyle]}
>
Expand Down