Skip to content

Horizontal view doesn't render correctly if an item height changes after mount #528

Description

@eliezra236
function ExpandedItem() {
    const [isExpanded, setIsExpanded] = useState(false);

    return (
        <Pressable
            onPress={() => setIsExpanded((curr) => !curr)}
            style={{
                height: isExpanded ? 200 : 100,
                backgroundColor: 'blue',
            }}
        ></Pressable>
    );
}

function BugLegendListTest() {
    return (
        <>
            <FlatList
                data={[1, 2, 3]}
                horizontal
                contentContainerStyle={{
                    gap: 16,
                    alignItems: 'flex-end',
                }}
                keyExtractor={(item) => String(item)}
                renderItem={(item) => (
                    <View className="w-32">
                        <Text>{item.item}</Text>
                        <ExpandedItem />
                    </View>
                )}
            />
            <View className="mt-5"></View>
            <LegendList
                data={[1, 2, 3]}
                horizontal
                contentContainerStyle={{
                    gap: 16,
                    alignItems: 'flex-end',
                }}
                keyExtractor={(item) => String(item)}
                renderItem={(item) => (
                    <View className="w-32">
                        <Text>{item.item}</Text>
                        <ExpandedItem />
                    </View>
                )}
            />
        </>
    );
}

I created this simple example to show the issue

This is how it looks if the items are not expanded.
Image

And this is how it looks when the item is expanded on both FlatList and LegendList
Image

The FlatList expand and show the full item, while LegendList cut the item, since the view only shows the original size still, and the rest remain out of view.

Tested with version 3.3.7

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions