Skip to content

fix: correct counter axis logic in getDirection function#232

Open
lordke wants to merge 1 commit intoGLips:mainfrom
lordke:fix/getDirection-counter-axis-logic
Open

fix: correct counter axis logic in getDirection function#232
lordke wants to merge 1 commit intoGLips:mainfrom
lordke:fix/getDirection-counter-axis-logic

Conversation

@lordke
Copy link

@lordke lordke commented Aug 27, 2025

Problem Description

The getDirection function has incorrect logic for the counter axis. Currently, the counter axis returns the same direction as the primary axis, which is incorrect in flexbox layout systems.

Fix Details

This PR corrects the counter axis logic:

  • When mode is "row": primary axis is horizontal, counter axis should be vertical
  • When mode is "column": primary axis is vertical, counter axis should be horizontal

Files Changed

  • src/transformers/layout.ts: Fixed the return values for counter axis in getDirection function

Before/After Comparison

Before (incorrect):

case "counter":
  switch (mode) {
    case "row":
      return "horizontal"; // Wrong: should be vertical
    case "column":
      return "vertical";   // Wrong: should be horizontal
  }

After (correct):

case "counter":
  switch (mode) {
    case "row":
      return "vertical";   // Correct: cross axis of row is vertical
    case "column":
      return "horizontal"; // Correct: cross axis of column is horizontal
  }

@lordke lordke force-pushed the fix/getDirection-counter-axis-logic branch from cf1c7cd to 0966434 Compare August 27, 2025 14:20
The getDirection function was incorrectly returning the same direction for both primary and counter axes. In flexbox layout:
- When mode is 'row': primary axis is horizontal, counter axis should be vertical
- When mode is 'column': primary axis is vertical, counter axis should be horizontal

This fix ensures the counter axis returns the perpendicular direction to the primary axis.
@lordke lordke force-pushed the fix/getDirection-counter-axis-logic branch from 0966434 to 88eb92c Compare August 27, 2025 14:21
@GLips
Copy link
Owner

GLips commented Aug 27, 2025

Nice find @lordke—this definitely seems like a bug to me.

Can you put together a public Figma design that demonstrates the issue? Would love to test the output before and after the fix before I merge it.

@GLips
Copy link
Owner

GLips commented Sep 2, 2025

Hey @lordke, just wanted to follow up on the above—like I said this does seem like a bug to me, but I put together some tests and haven't been able to identify the specific issue. All my designs seem to be output correctly in HTML when translated through the MCP.

Do you have a broken design you can share?

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.

2 participants