Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text Truncation doesn't work in TouchableHighlight in a FlatList #25285

Closed
abp437 opened this issue Jun 17, 2019 · 1 comment
Closed

Text Truncation doesn't work in TouchableHighlight in a FlatList #25285

abp437 opened this issue Jun 17, 2019 · 1 comment
Labels
Bug Component: FlatList Component: TouchableHighlight Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@abp437
Copy link

abp437 commented Jun 17, 2019

React Native version:
0.59.1

Description

I've a basic component in which I have added support only for portrait mode inside my app, so I need the text truncated at the end of line, but text truncation doesn't seem to work with the numberOfLines prop for TouchableHighlight in a FlatList.
Also please note I need TouchableHighlight since I want to navigate to different routes on press of the TouchableHighlight.
I'd expected the text to truncate at the end.
Please guide me with what's going wrong here.

Steps To Reproduce:

  • Just run the below code in a React Native File
import React, { useState, useEffect } from 'react';
import {
    TouchableHighlight, FlatList, View, Text,
} from 'react-native';

const SomeComponent = () => {
    const [list, setList] = useState([]);

    useEffect(() => {
        fetch('https://jsonplaceholder.typicode.com/todos')
            .then(response => response.json())
            .then(listData => setList(listData));
    }, []);

    return (
        <FlatList
            style={{
                flex: 1,
            }}
            data={list}
            renderItem={({ item }) => (
                <TouchableHighlight
                    underlayColor="#eee"
                    style={{
                        display: 'flex',
                        flexDirection: 'row',
                        borderBottomColor: '#bdbdbd',
                        borderBottomWidth: 1,
                        paddingVertical: 12,
                        paddingHorizontal: 15,
                    }}
                    onPress={() => console.log('Clicked Me')}
                >
                    <View style={{ display: 'flex', flexDirection: 'row' }}>
                        <View style={{
                            width: 50,
                            height: 50,
                            backgroundColor: '#bdbdbd',
                            borderRadius: 50 / 2,
                        }}
                        />
                        <View style={{ marginLeft: 10 }}>
                            <Text
                                numberOfLines={1}
                                style={{
                                    flex: 1,
                                    fontWeight: '700',
                                }}
                            >
                                {item.title}
                            </Text>
                            <Text>Something</Text>
                        </View>
                    </View>
                </TouchableHighlight>
            )}
            keyExtractor={item => item.id.toString()}
        />
    );
};

export default SomeComponent;

@stale
Copy link

stale bot commented Sep 15, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Sep 15, 2019
@abp437 abp437 closed this as completed Sep 21, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Sep 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: FlatList Component: TouchableHighlight Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

2 participants