Skip to content

flex-flow drops -reverse: column-reverse becomes column, wrap-reverse becomes wrap #215

Open

Description

@trackoor

Passing row-reverse, column-reverse, or wrap-reverse to the flex-flow shorthand returns row, column, or wrap instead of the -reverse keyword.

// repro.js
const transform = require("css-to-react-native").default;
for (const v of ["column-reverse", "row-reverse wrap", "wrap-reverse", "wrap-reverse column-reverse"]) {
  console.log(`flex-flow: ${v} ->`, JSON.stringify(transform([["flex-flow", v]])));
}
$ node repro.js
flex-flow: column-reverse -> {"flexWrap":"nowrap","flexDirection":"column"}
flex-flow: row-reverse wrap -> {"flexWrap":"wrap","flexDirection":"row"}
flex-flow: wrap-reverse -> {"flexWrap":"wrap","flexDirection":"row"}
flex-flow: wrap-reverse column-reverse -> {"flexWrap":"wrap","flexDirection":"column"}

Expected flexDirection: "column-reverse" / "row-reverse" and flexWrap: "wrap-reverse" respectively. Setting flex-direction: column-reverse or flex-wrap: wrap-reverse directly works.

In src/transforms/flexFlow.ts, FLEX_WRAP and FLEX_DIRECTION use unanchored regexes (/(nowrap|wrap|wrap-reverse)/ and /(row|row-reverse|column|column-reverse)/), so node.value.match(regExp) matches the wrap, row, or column prefix first. Anchoring them with /^(...)$/ (as border.ts and font.ts do) fixes the issue.

Versions tested: css-to-react-native 3.2.0 and master (3f4899b) on Node v26.13.0.

Credit: https://ucsbplse.github.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions