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

Add numberOfLines prop to DataTableTitle #863

Merged
merged 2 commits into from
Feb 22, 2019
Merged

Add numberOfLines prop to DataTableTitle #863

merged 2 commits into from
Feb 22, 2019

Conversation

Taym95
Copy link
Collaborator

@Taym95 Taym95 commented Feb 22, 2019

Add a numberOfLines prop to DataTable.Title
Try to fix #848

@callstack-bot
Copy link

callstack-bot commented Feb 22, 2019

Hey @Taym95, thank you for your pull request 🤗. The documentation from this branch can be viewed here. Please remember to update Typescript types if you changed API.

@@ -99,7 +104,7 @@ class DataTableTitle extends React.Component<Props, State> {
styles.cell,
sortDirection ? styles.sorted : { color: textColor },
]}
numberOfLines={1}
numberOfLines={numberOfLines || 1}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use defaultProps for the default value

@satya164 satya164 merged commit f9a0949 into callstack:master Feb 22, 2019
@satya164
Copy link
Member

@allcontributors[bot] let's add @Taym95 to contributors for code

@iamautomaton
Copy link

Hi, i am developing the web app using react native. I found this plugin and it is useful for me. However, my datatable title is too long so i add numberofLines want to solve the problem, it doesn't work. It still showing "..." of my long title. Hope can fix this issue. Thanks

@Trancever
Copy link
Contributor

@iamautomaton That's how numberOfLines works. It truncates the text and append 3 dots to the end.

@iamautomaton
Copy link

iamautomaton commented Dec 12, 2019

@Trancever Maybe i am not explaining clearly, i will make it more easy to understand.

I am writing a report page, i am designing a form which is showing the detail of some applicant information. i want to show "English Name of Applicant" on one of my form title of my report page. However, i set the numberOfLines to two, it still showing one line with "...". I am expecting it will show two line of the title

Expected

English Name of
Applicant

Actually

English Name of App...

Below is my code and the ScreenCap

Code:

<DataTable.Header>
....
<DataTable.Title numberOfLines={2} style={{alignSelf:'stretch',justifyContent:"center",padding:10,width:150,flexDirection:'row'}}><Text style={{flex: 1, flexWrap: 'wrap'}}>English Name of Applicant</DataTable.Title>
<DataTable.Title style={{alignSelf:'stretch',justifyContent:"center",padding:10,width:150,flexDirection:'row' }}><Text style={{flex: 1, flexWrap: 'wrap'}}>Phone Number</DataTable.Title>
<DataTable.Title style={{alignSelf:'stretch',justifyContent:"center",padding:10,width:150,flexDirection:'row' }}><Text style={{flex: 1, flexWrap: 'wrap'}}>Address</DataTable.Title>
....
</DataTable.Header>

ScreenCap:
Simulator Screen Shot - iPad 5th 12 4 - 2019-12-12 at 09 21 06

@Surangaup
Copy link

@Trancever Maybe i am not explaining clearly, i will make it more easy to understand.

I am writing a report page, i am designing a form which is showing the detail of some applicant information. i want to show "English Name of Applicant" on one of my form title of my report page. However, i set the numberOfLines to two, it still showing one line with "...". I am expecting it will show two line of the title

Expected

English Name of
Applicant

Actually

English Name of App...

Below is my code and the ScreenCap

Code:

<DataTable.Header>
....
<DataTable.Title numberOfLines={2} style={{alignSelf:'stretch',justifyContent:"center",padding:10,width:150,flexDirection:'row'}}><Text style={{flex: 1, flexWrap: 'wrap'}}>English Name of Applicant</DataTable.Title>
<DataTable.Title style={{alignSelf:'stretch',justifyContent:"center",padding:10,width:150,flexDirection:'row' }}><Text style={{flex: 1, flexWrap: 'wrap'}}>Phone Number</DataTable.Title>
<DataTable.Title style={{alignSelf:'stretch',justifyContent:"center",padding:10,width:150,flexDirection:'row' }}><Text style={{flex: 1, flexWrap: 'wrap'}}>Address</DataTable.Title>
....
</DataTable.Header>

ScreenCap:
Simulator Screen Shot - iPad 5th 12 4 - 2019-12-12 at 09 21 06

Did you fix this?

mikehardy added a commit to mikehardy/react-native-paper that referenced this pull request Dec 17, 2021
Without this, it does not appear the numberOfLines prop has an effect, as noticed in callstack#848 and callstack#863
With this, it appears to work exactly as expected.
mikehardy added a commit to mikehardy/react-native-paper that referenced this pull request Dec 17, 2021
Without this, it does not appear the numberOfLines prop has an effect, as noticed in callstack#848 and callstack#863
With this, it appears to work exactly as expected.

Text components require special alignment treatment with word wrapping. Normally a word wrap
will force text alignment to flex-start. So we align directly when number of lines is > 1, while
respecting the numeric property and it's interaction with RTL languages
@mikehardy
Copy link
Contributor

I think I repaired the original implementation so that it handles text component's special text alignment issues with wrapping, while allowing a cell height that is a multiple of numberOfLines - patch-package patch available here for testing: #3015 (comment)

mikehardy added a commit to mikehardy/react-native-paper that referenced this pull request Mar 29, 2022
Without this, it does not appear the numberOfLines prop has an effect, as noticed in callstack#848 and callstack#863
With this, it appears to work exactly as expected.

Text components require special alignment treatment with word wrapping. Normally a word wrap
will force text alignment to flex-start. So we align directly when number of lines is > 1, while
respecting the numeric property and it's interaction with RTL languages
@mikehardy
Copy link
Contributor

My PR attempting to address this is release now in 4.12.0, hopefully it works for everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataTable Header Text Wrap
7 participants