Coder Social home page Coder Social logo

Comments (11)

NickGerleman avatar NickGerleman commented on August 26, 2024 2

The above code mentioned is unfortunately only used in the legacy architecture. The new architecture has a different path for setting text direction, though I think it may also do some swapping (though IIRC maybe only when swapLeftAndRightInRTL is enabled, which I think is default too).

from react-native.

cortinico avatar cortinico commented on August 26, 2024 1

@cortinico I can pick this up, but had a few points.

those are good questions for @necolas

from react-native.

kunalchavhan avatar kunalchavhan commented on August 26, 2024

Hello, Can I try to resolve this issue?

from react-native.

samrith-s avatar samrith-s commented on August 26, 2024

@cortinico I can pick this up, but had a few points.

If we are to match web specs, then the way left and right currently behave don't work according to the specs. It internally checks whether the direction is RTL or LTR, and applies the opposite.

According to the CSS spec:

  • left aligns the text to the left of the bounding box
  • right aligns the text to the right of the bounding box
  • start aligns the text to the left if LTR and right if RTL
  • end aligns the text to the right if LTR and left if RTL

Based on this, I can see two ways to do it:

  • Either accommodate for this change in the Text component itself
  • Fix this in the base text shadow node to match the spec

Which one would you recommend?

from react-native.

samrith-s avatar samrith-s commented on August 26, 2024

@necolas whenever you can, if you can validate these points then I will make the fix accordingly.

I have already done the same for Android, but awaiting confirmation will do the for iOS.

from react-native.

necolas avatar necolas commented on August 26, 2024

then the way left and right currently behave don't work according to the specs. It internally checks whether the direction is RTL or LTR, and applies the opposite

Fixing this might be a breaking change if you're saying left currently becomes right in an RTL context.

should react to the direction style on ancestral Views

I think the fix to the way direction works on Android is behind a feature flag. cc @NickGerleman

from react-native.

samrith-s avatar samrith-s commented on August 26, 2024

What do you recommend?

I am particularly referring to these lines:

private int getTextAlign() {
int textAlign = mTextAlign;
if (getLayoutDirection() == YogaDirection.RTL) {
if (textAlign == Gravity.RIGHT) {
textAlign = Gravity.LEFT;
} else if (textAlign == Gravity.LEFT) {
textAlign = Gravity.RIGHT;
}
}
return textAlign;
}

I suspect something similar will also be there for iOS. If we add start and end support, do we just swap it out for left and right, or actually follow the spec and implement it as per it?

from react-native.

samrith-s avatar samrith-s commented on August 26, 2024

@NickGerleman in that case, can you point me to where this would be?

@necolas Should the fix for this be inline with CSS spec? If so then I will start accordingly.

from react-native.

samrith-s avatar samrith-s commented on August 26, 2024

@necolas Hello, any update on this? I can pick this up accordingly.

from react-native.

necolas avatar necolas commented on August 26, 2024

Yes, inline with CSS spec

from react-native.

samrith-s avatar samrith-s commented on August 26, 2024

Cool, sorry for the delay was unwell. I'll pick this up over this weekend!

from react-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.