Skip to content

fix: dont parse flex: 1#543

Merged
Brentlok merged 1 commit into
mainfrom
fix/parse-flex-1
May 21, 2026
Merged

fix: dont parse flex: 1#543
Brentlok merged 1 commit into
mainfrom
fix/parse-flex-1

Conversation

@Brentlok
Copy link
Copy Markdown
Contributor

@Brentlok Brentlok commented May 21, 2026

fixes #542

Summary by CodeRabbit

  • Refactor

    • Enhanced CSS value processing with context-aware parsing for flex shorthand properties, providing optimized value representation.
  • Tests

    • Updated test suite to validate improved CSS flex shorthand property handling in layout utilities.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3b21db5b-7338-40c4-946e-6794add9b237

📥 Commits

Reviewing files that changed from the base of the PR and between ef09d80 and 1693c0e.

📒 Files selected for processing (5)
  • packages/uniwind/src/bundler/css-processor/css.ts
  • packages/uniwind/src/bundler/css-processor/processor.ts
  • packages/uniwind/src/bundler/css-processor/types.ts
  • packages/uniwind/tests/native/styles-parsing/layout.test.tsx
  • packages/uniwind/tests/test.css

📝 Walkthrough

Walkthrough

CSS processor now accepts the target CSS property name during value processing. For flex property declarations matching flex: 1, the processor preserves the shorthand instead of expanding to individual properties. Processor.ts threads the property through the pipeline, and tests validate both shorthand and expanded forms.

Changes

Flex Shorthand Detection in CSS Processor

Layer / File(s) Summary
Type definition for property context
packages/uniwind/src/bundler/css-processor/types.ts
Adds DeclarationProperty type alias mapping to Declaration['property'] for passing CSS property names through the processing pipeline.
Flex shorthand detection logic
packages/uniwind/src/bundler/css-processor/css.ts
processValue and getProcessedValue signatures updated to accept optional declarationProperty. When processing flex property with components flexGrow: 1, flexShrink: 1, flexBasis: "0%", returns { flex: 1 } shorthand instead of expanded object.
Property context threading
packages/uniwind/src/bundler/css-processor/processor.ts
ProcessorBuilder.addDeclaration passes declaration.property to CSS.processValue, enabling context-aware property processing in the CSS handler.
Test validation
packages/uniwind/tests/test.css, packages/uniwind/tests/native/styles-parsing/layout.test.tsx
Test utilities and assertions validate that flex: 1 shorthand is preserved in flex-1 while flex-1-custom with expanded flex declarations maintains individual properties.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A flex shorthand springs to life,
No more expanded strife,
When one and one and zero meet,
flex: 1 makes layouts neat! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: dont parse flex: 1' is clear and concise, directly addressing the main change which prevents parsing flex: 1 as a shorthand.
Linked Issues check ✅ Passed The PR implements context-aware CSS property processing that prevents incorrect flex: 1 shorthand parsing, which aligns with the issue's goal of fixing flaky height measurements caused by improper flex property handling.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the flex: 1 parsing issue through updated CSS processing logic and corresponding test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/parse-flex-1

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Brentlok Brentlok merged commit 43b1845 into main May 21, 2026
2 checks passed
@Brentlok Brentlok deleted the fix/parse-flex-1 branch May 21, 2026 06:42
@github-actions
Copy link
Copy Markdown
Contributor

🚀 This pull request is included in v1.7.0. See Release v1.7.0 for release notes.

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.

Height mesurement flaky when list header has flex: 1

1 participant