Skip to content

refactor(props): allow negative values for position attributes#566

Open
azamat7g wants to merge 2 commits into
johnfercher:masterfrom
azamat7g:feature/negative-padding
Open

refactor(props): allow negative values for position attributes#566
azamat7g wants to merge 2 commits into
johnfercher:masterfrom
azamat7g:feature/negative-padding

Conversation

@azamat7g

@azamat7g azamat7g commented May 1, 2026

Copy link
Copy Markdown

Removed constraints enforcing non-negative values for Top, Left, Right, and Bottom attributes across components. Adjusted tests to account for preserving negative values.

Description
Allows negative values for Top / Bottom / Left / Right on props.Text, props.Barcode, and props.Checkbox. Previously MakeValid clamped any negative offset back to 0, silently killing inputs like { "padding": { "top": -3, "left": -2 } } that downstream JSON specs forward to the renderer.

Purely additive: >= 0 values keep their existing behavior; only the previously-impossible < 0 cases start working. Fields with a real geometric reason to refuse negatives (Size, Percent, Proportion, VerticalPadding, font
fallbacks) keep their clamps.

Provider-side upper-bound checks (if textProp.Top > cell.Height etc.) are unaffected — they clamp too-positive values, not too-negative ones.

Related Issue
N/A

Checklist

  • All methods associated with structs has func (<first letter of struct> *struct) method() {} name style.
  • Wrote unit tests for new/changed features.
  • Followed the unit test when,should naming pattern.
  • All mocks created with m := mocks.NewConstructor(t).
  • All mocks using m.EXPECT().MethodName() method to mock methods.
  • Updated docs/*
  • Updated example_test.go.
  • Updated README.md
  • New public methods/structs/interfaces has comments upside them explaining they responsibilities
  • Executed make dod with none issues pointed out by golangci-lint

Azamat added 2 commits May 1, 2026 12:01
Removed constraints enforcing non-negative values for `Top`, `Left`, `Right`, and `Bottom` attributes across components. Adjusted tests to account for preserving negative values.
@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 750b4327-2681-4041-8e0d-0e9ceb24b5d5

📥 Commits

Reviewing files that changed from the base of the PR and between aa2645f and 216fbf9.

📒 Files selected for processing (9)
  • docs/v2/features/barcode.md
  • docs/v2/features/checkbox.md
  • docs/v2/features/text.md
  • pkg/props/barcode.go
  • pkg/props/barcode_test.go
  • pkg/props/checkbox.go
  • pkg/props/checkbox_test.go
  • pkg/props/text.go
  • pkg/props/text_test.go
💤 Files with no reviewable changes (3)
  • pkg/props/checkbox.go
  • pkg/props/barcode.go
  • pkg/props/text.go

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Barcode, Checkbox, and Text components now support negative offset values for Left, Top, Bottom, and Right properties, enabling precise positioning of elements outside their cell boundaries.
  • Tests

    • Updated test expectations to validate negative offset handling across all affected components.

Walkthrough

Documentation and validation logic for three components (Barcode, Checkbox, Text) were updated to allow negative values for positional properties. Minimum value clamping was removed from their MakeValid methods, enabling elements to render outside cell boundaries. Tests were updated to verify the new behavior.

Changes

Cohort / File(s) Summary
Documentation Updates
docs/v2/features/barcode.md, docs/v2/features/checkbox.md, docs/v2/features/text.md
Updated property descriptions to explicitly document that Left/Top and margin/offset fields now accept negative values for rendering elements outside cell boundaries.
Validation Logic
pkg/props/barcode.go, pkg/props/checkbox.go, pkg/props/text.go
Removed minimum value clamping for positional properties. Barcode and Checkbox no longer clamp Left/Top to 0.0; Text no longer clamps Top/Bottom/Left/Right. Other validations (defaults, bounds checks) remain unchanged.
Test Expectations
pkg/props/barcode_test.go, pkg/props/checkbox_test.go, pkg/props/text_test.go
Updated test assertions to verify negative positional values are preserved rather than clamped to 0.0. Subtest descriptions updated to reflect new semantics.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 With whiskers twitching, hopped with glee,
Negative bounds now wild and free!
Beyond the cells we'll nudge and slide,
No clamping claws to seal our pride,
Three components leap with cheer! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing constraints that enforced non-negative values for position attributes across multiple components.
Description check ✅ Passed The description comprehensively explains the changes, rationale, and scope. All critical checklist items are marked as completed, including unit tests, documentation updates, and linting.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

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.

1 participant