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

textAlign: 'justify' not working #202

Closed
rochapablo opened this issue Nov 30, 2018 · 13 comments
Closed

textAlign: 'justify' not working #202

rochapablo opened this issue Nov 30, 2018 · 13 comments
Labels
bug:upstream The bug is caused by a third party library. bug Crush'em all.

Comments

@rochapablo
Copy link

Is this a bug report or a feature request?

bug report.

Have you read the guidelines regarding bug report?

Yes, I did.

Have you read the documentation in its entirety?

Yes, I did.

Have you made sure that your issue hasn't already been reported/solved?

I'm sure of that.

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

I'm only testing on Android.

Is the bug reproductible in a production environment (not a debug one)?

Never tried. But pretty sure that gets the same result.

Have you been able to reproduce the bug in the provided example?

I'm gonna say no and keep going, hopping for the best.

Environment

Environment:
React: 16.6.0-alpha.8af6728
React native: 0.57.4
react-native-render-html: 3.10.0

Target Platform:
Android (7.0)

Steps to Reproduce

I'm just expecting for textAlign:'justify' work, so...

import HTML from 'react-native-render-html';

const styles = {
      a: {
        color: style.content.link.color,
        fontWeight: '300',
      },
      p: {
        color: this.props.data.color,
        fontSize: this.props.data.fontSize,
        lineHeight: this.props.data.lineHeight,
        marginBottom: 0,
        marginTop: 0,
        paddingBottom: 0,
        paddingTop: 0,
        textAlign: 'justify',
      },
    };

<HTML html={this.props.content} imagesMaxWidth={Dimensions.get('window').width}
                tagsStyles={styles}
                baseFontStyle={styles.p}
              />

Expected Behavior

Expect justified paragraphs. But only works with textAlign right or center.

Actual Behavior

It gets align to left as default I guess.

Reproducible Demo

Sorry, but I'm just hopping for the best.

@clytras
Copy link

clytras commented Jan 23, 2019

Maybe This is related to this RN spec:

textAlign: enum('auto', 'left', 'right', 'center', 'justify')

Specifies text alignment. The value 'justify' is only supported on iOS and fallbacks to left on Android.

Android does not support justify for textAlign.

https://facebook.github.io/react-native/docs/text

@jariwalabhavesh
Copy link

@clytras : Yes justify is not working in android. In ios, it just works fine. Is there any workaround for android?

@poison8
Copy link

poison8 commented Apr 1, 2019

react-native 0.59 render-html 4.1.2 not working justify for textAlign .

@successanil
Copy link

@clytras : Yes justify is not working in android. In ios, it just works fine. Is there any workaround for android?

Yes that feature is not supported natively by Android OS , thats why react native can't do it from outside but as a workaround you can use webview (kinda dirty solution) .

@GabrielePrestifilippo
Copy link

As of now, from react-native 0.60, the justify works on android too (API >=26) https://facebook.github.io/react-native/docs/text#docsNav

@jsamr jsamr added the bug Crush'em all. label Jul 4, 2020
@jsamr
Copy link
Collaborator

jsamr commented Jul 5, 2020

I am closing because the issue is upstream (react native) and has been fixed since release 0.60.

@jsamr jsamr closed this as completed Jul 5, 2020
@jsamr jsamr added the bug:upstream The bug is caused by a third party library. label Jul 5, 2020
@noumantahir
Copy link

noumantahir commented Jan 26, 2022

@jsamr Apparently I am facing this issue on RN 0.60+ and Android API 31, rendering with textAlign:'justify' not working as expected.. it works with regular Text component but not working with RenderHtml package... I did double check if prop is actually being passed to right tag as well.

Screenshot 2022-01-27 at 12 06 24 AM

Screenshot 2022-01-27 at 12 05 09 AM

Facing issue only on Android, iOS side words as expected. Moreover on android side the textAligh:'justify' is rather causing the text lines to be clipped at the end, it may be our clue to resolving the issue.

Screenshot 2022-01-27 at 12 08 52 AM

Github issue reference: ecency/ecency-mobile#2157

@jsamr
Copy link
Collaborator

jsamr commented Jan 26, 2022

it works with regular Text component but not working with RenderHtml package...

@noumantahir I suggest that you provide a full reproduction in a separate ticket, with the exact HTML snippet, library version and React Native version, and I will be happy to investigate and test on my machine! https://github.com/meliorence/react-native-render-html/issues/new/choose

@noumantahir
Copy link

noumantahir commented Jan 27, 2022

@jsamr apologies for inconvenience, I dug more deep today, apparently if we set selectable prop to true, the textAlign:'justify' stops working. That makes it an issue with react-native and not with render-html.

Sample code attached anyways, if we set selectable to false, the text will start justifying.

    <RenderHTML 
      source={{ html:`<p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's  </p>` }}
      tagsStyles={{
        p:{textAlign:'justify'}
      }}
      defaultTextProps={{
        selectable:true
      }}
    />

@jsamr
Copy link
Collaborator

jsamr commented Jan 27, 2022

@noumantahir No worries! It is yet another layout bug in React involving Text... that is worth mentioning in the FAQ page.

@dimmu123
Copy link

dimmu123 commented Dec 9, 2022

@jsamr apologies for inconvenience, I dug more deep today, apparently if we set selectable prop to true, the textAlign:'justify' stops working. That makes it an issue with react-native and not with render-html.

Sample code attached anyways, if we set selectable to false, the text will start justifying.

    <RenderHTML 
      source={{ html:`<p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's  </p>` }}
      tagsStyles={{
        p:{textAlign:'justify'}
      }}
      defaultTextProps={{
        selectable:true
      }}
    />

This fixed my issue. Thanks!

@agunbuhori
Copy link

In 2023, still not working to add 'textAlign: justify' on android. Please help

@longhaha1998
Copy link

In 2024, still not working to add 'textAlign: justify' on android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:upstream The bug is caused by a third party library. bug Crush'em all.
Projects
None yet
Development

No branches or pull requests