Skip to content

fix(core): use full border width for inner content offset in LayoutEngine to prevent child widgets overlapping border#691

Open
ionfwsrijan wants to merge 1 commit into
Karanjot786:mainfrom
ionfwsrijan:fix-682-layout-border-offset
Open

fix(core): use full border width for inner content offset in LayoutEngine to prevent child widgets overlapping border#691
ionfwsrijan wants to merge 1 commit into
Karanjot786:mainfrom
ionfwsrijan:fix-682-layout-border-offset

Conversation

@ionfwsrijan
Copy link
Copy Markdown

@ionfwsrijan ionfwsrijan commented Jun 4, 2026

Description

The layout engine computes the inner content area's x/y offset as padding + border / 2. For a 1-cell border, border.horizontal / 2 = 0.5, which becomes 0 after Math.floor(). Child widgets are placed at the parent's top-left corner, directly overlapping the border characters.

Root Cause

LayoutEngine.ts:88-89 used border.horizontal / 2 and border.vertical / 2 for the inner content offset, which after Math.floor() rounded to 0 for standard 1-cell borders.

Fix

Changed border.horizontal / 2border.horizontal and border.vertical / 2border.vertical so the inner content starts at the correct position after the border.

Changes

  • packages/core/src/layout/LayoutEngine.ts:88-89 — use full border width for inner content offset

Closes #682

Summary by CodeRabbit

  • Bug Fixes
    • Fixed layout positioning calculations to correctly account for border thickness when determining child element placement within containers.

…gine to prevent child widgets overlapping border

Closes Karanjot786#682
@ionfwsrijan ionfwsrijan requested a review from Karanjot786 as a code owner June 4, 2026 09:33
@github-actions github-actions Bot added type:bug +10 pts. Bug fix. area:core @termuijs/core labels Jun 4, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0018199d-8aee-4956-8645-26919eb7b5e8

📥 Commits

Reviewing files that changed from the base of the PR and between c36cc8c and 15dac49.

📒 Files selected for processing (1)
  • packages/core/src/layout/LayoutEngine.ts

📝 Walkthrough

Walkthrough

This PR fixes a layout positioning bug in the core engine where child widgets within bordered containers were positioned with an incorrect offset. The inner content origin now correctly uses full border thickness instead of half-border thickness when calculating where flex layout content starts.

Changes

Border Offset Calculation Fix

Layer / File(s) Summary
Inner content offset adjustment
packages/core/src/layout/LayoutEngine.ts
Lines 88–89 corrected to offset child widgets by full border thickness (border.horizontal and border.vertical) rather than half-border values, ensuring children position outside the parent border instead of overlapping it.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

area:core, level:advanced, quality:exceptional

Suggested reviewers

  • Karanjot786

Poem

A border that once was split in half,
Now stands complete, drawn with full path,
No more children creeping through the line,
Layout's inner truth shines fine! 🐰✨

🚥 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 clearly and specifically describes the main change: using full border width for inner content offset in LayoutEngine to prevent child widget overlap.
Description check ✅ Passed The description includes all essential sections: problem statement, root cause analysis, specific fix applied, and issue closure reference with relevant file locations.
Linked Issues check ✅ Passed The PR code changes directly address issue #682's requirements: replacing border division by 2 with full border width in LayoutEngine.ts lines 88-89 to prevent child widget overlap.
Out of Scope Changes check ✅ Passed All changes are scoped to the specific issue: only LayoutEngine.ts lines 88-89 were modified to fix the inner content offset calculation, with no unrelated changes present.

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

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

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

@ionfwsrijan
Copy link
Copy Markdown
Author

@Karanjot786 You may review and merge

@Karanjot786 Karanjot786 added gssoc:approved Approved PR. Earns +50 base points. quality:clean x 1.2 multiplier. Clean implementation. level:intermediate +35 pts. Moderate task. type:feature +10 pts. New feature. labels Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core @termuijs/core gssoc:approved Approved PR. Earns +50 base points. level:intermediate +35 pts. Moderate task. quality:clean x 1.2 multiplier. Clean implementation. type:bug +10 pts. Bug fix. type:feature +10 pts. New feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] LayoutEngine Uses border.horizontal / 2 Instead of border.horizontal for Inner Content Offset

2 participants