Repository navigation
Conversation
Android's Fabric TextInput ignores `paddingBlock` / `paddingInline` — the value is dropped and the EditText theme default (~21dp) remains, so `py-2` measures 42.67dp on a real device instead of 35.81dp. Tailwind compiles `py-*` / `px-*` to exactly those logical properties, so nearly every text input is affected. Convert to physical properties after className resolution. Existing physical values win.
There was a problem hiding this comment.
Pull request overview
This PR aims to work around an Android Fabric TextInput issue where logical padding shorthands (paddingBlock / paddingInline, commonly produced by Tailwind py-* / px-*) are ignored, by expanding them into non-logical padding properties during getStyledProps processing.
Changes:
- Adds a post-merge transformation step in
getStyledPropsto expand logical padding properties on the resolvedstyle. - Introduces
expandLogicalPadding()to recursively handle style objects and arrays, preserving existing physical values.
Suppressed comments (2)
src/native/styles/index.ts:357
paddingInlineis a logical (start/end) shorthand. Expanding it topaddingLeft/paddingRightchanges behavior in RTL layouts. To preserve inline semantics while still avoidingpaddingInline, preferpaddingStart/paddingEnd(and keep the same “existing values win” behavior).
if (paddingInline !== undefined) {
next.paddingLeft ??= paddingInline;
next.paddingRight ??= paddingInline;
}
src/native/styles/index.ts:308
- This change alters the runtime style output (e.g.
px-*/py-*will no longer surface aspaddingInline/paddingBlock). Existing Tailwind vendor tests assert the old shape (e.g.src/__tests__/vendor/tailwind/spacing.test.tsx,src/__tests__/vendor/tailwind/@apply.test.tsx) and should be updated or supplemented to cover the new expansion behavior.
if (result.style !== undefined) {
result.style = expandLogicalPadding(result.style);
}
| if (result.style !== undefined) { | ||
| result.style = expandLogicalPadding(result.style); | ||
| } |
| if (Array.isArray(style)) { | ||
| let changed = false; | ||
| const next = style.map((entry) => { | ||
| const expanded = expandLogicalPadding(entry); | ||
| if (expanded !== entry) { | ||
| changed = true; | ||
| } | ||
| return expanded; | ||
| }); | ||
| return changed ? next : style; | ||
| } |
sammoore
left a comment
There was a problem hiding this comment.
@kdwkr Made a compile-time only version in the form of #580 -- simply mapping over to paddingVertical/paddingHorizontal. As far as I can tell, there's nothing wrong with that, and we avoid any potential runtime performance hits from allocations on the hot path (which we are also trying to optimize on an ongoing basis).
Let me know if you have any concerns that it won't solve the underlying issue or tangential ones, and we can revisit!
…ical/paddingHorizontal Android's Fabric TextInput applies its EditText theme padding (about 21dp) to every edge it finds no padding for, and it only checks padding, paddingVertical/paddingHorizontal and the single sides. React Native maps paddingBlock and paddingInline to the same Yoga edges as paddingVertical and paddingHorizontal, but that check doesn't see them. So a Tailwind py-*/px-* TextInput kept the theme padding. Renaming the keys at compile time fixes literal and var() values alike (propertyRename covers the unparsed path), costs nothing at runtime, and renders the same as before on every other component. Nativewind v4 rendered physical keys for py-*/px-*, so this fixes a v4 regression. Diagnosed in nativewind#400, which expanded the keys at runtime instead. Co-authored-by: Daewoon Kim <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ontal (#580) Supersedes #400. Co-authored-by: Daewoon Kim <[email protected]>
Android's Fabric
TextInputignores logical padding (paddingBlock/paddingInline). The value is dropped and the EditText theme default (~21dp) stays, so apy-2input measures 42.67dp on a real device instead of 35.81dp. Measured on a Samsung SM-M236L, density 2.625, RN 0.86.2 new architecture.Tailwind compiles
py-*/px-*to exactly those logical properties, so in practice nearly every text input is affected.Rewriting call sites to
pt-*/pb-*is not a workaround — a Tailwind class sorter (prettier-plugin-tailwindcss, oxfmt) collapses them straight back topy-*.This expands logical padding to physical properties in
getStyledProps, after className resolution, so it covers every path that produces a style. Existing physical values win, so an explicitpaddingTopis never overwritten. Arrays are handled and the input object is returned unchanged when there is nothing to expand.