Skip to content

fix: map text-align start/end to left/right - #471

Open
Abdalkaderdev wants to merge 1 commit into
nativewind:mainfrom
Abdalkaderdev:fix-text-align-logical-values
Open

Abdalkaderdev wants to merge 1 commit into
nativewind:mainfrom
Abdalkaderdev:fix-text-align-logical-values

Conversation

@Abdalkaderdev

Copy link
Copy Markdown

Closes #454.

parseTextAlign only allowed auto|left|right|center|justify, so text-start and text-end — which Tailwind v4 emits as text-align: start|end — were dropped with a warning and no alignment applied.

React Native has no logical start/end for textAlign, but <Text> resolves left/right against the writing direction (Expo localization guide), so they already behave as the logical values. That means the mapping can happen at compile time and needs no runtime change.

Worth noting <TextInput> treats left/right as physical rather than logical — that is react/react-native#45255 and out of scope here.

Added text-start and text-end cases to the existing Text Align block in typography.test.tsx. Both fail on main and pass with the change. The 4 failing tests in src/__tests__/babel fail on a clean checkout of main too and are unrelated.

parseTextAlign only allowed auto/left/right/center/justify, so the
text-start and text-end utilities Tailwind v4 emits as text-align:
start/end were dropped with a warning and no alignment was applied.

React Native has no logical start/end for textAlign, but <Text>
resolves left/right against the writing direction, so they are already
the logical values and the mapping can be done at compile time with no
runtime change. <TextInput> treats them as physical, which is a
separate React Native issue (react/react-native#45255).

Closes nativewind#454
@Abdalkaderdev

Copy link
Copy Markdown
Author

Credit where it's due: the root cause and the start→left / end→right mapping are @Noitidart's analysis in #454, including the repro branches. I've only turned it into a patch with tests against the current main.

This branch has not been deployed

No deployments
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.

text-start/text-end silently dropped — parseTextAlign rejects logical values

1 participant