Skip to content

fix: disabling one border side no longer hides all sides - #696

Open
troclaux wants to merge 1 commit into
charmbracelet:mainfrom
troclaux:fix/border-style-partial-sides-vanish
Open

fix: disabling one border side no longer hides all sides#696
troclaux wants to merge 1 commit into
charmbracelet:mainfrom
troclaux:fix/border-style-partial-sides-vanish

Conversation

@troclaux

@troclaux troclaux commented Jun 2, 2026

Copy link
Copy Markdown

Fixes #194.

When a border style was set via BorderStyle(b) and then a single side was turned off (e.g. BorderTop(false)), the entire border disappeared instead of rendering the remaining three sides.

Root cause

applyBorder defaulted every unset side key to false, then relied on isBorderStyleSetWithoutSides() to flip them to true when no side key was present. That helper returns false the moment any side key exists — even one explicitly set to false — so calling BorderTop(false) caused all remaining sides to vanish.

Fix

  • borders.go: use defaultSide := border != noBorder so each unset side inherits true whenever a border style is active. The now-redundant isBorderStyleSetWithoutSides() block in applyBorder is removed.
  • unset.go: change UnsetBorder{Top,Right,Bottom,Left} to call BorderSide(false) (keeps the key in props as false) rather than removing the key, so "unset" consistently means "explicitly off" rather than "removed from props."

Before / after

// Before: entire border disappears
lipgloss.NewStyle().BorderStyle(lipgloss.NormalBorder()).BorderTop(false).Render("hi")
// → "hi"  (no border at all)

// After: only the top side is missing
// → │hi│
//   └──┘

…er hides all sides

When a border was set via BorderStyle (or BorderTop/Right/Bottom/Left calls
only), calling BorderTop(false) would remove the top side from the implicit
"all sides on" group and fall back to a raw false default, making every
unset side disappear.

Root cause: applyBorder defaulted all unset side keys to false, relying on
isBorderStyleSetWithoutSides() to flip them to true — but that helper
returns false the moment any side key is present, even when set to false.

Fix: use `defaultSide = border != noBorder` so each unset side inherits
true whenever a border style is active. Also change UnsetBorder{Top,Right,
Bottom,Left} to call BorderSide(false) (keeping the key in props as false)
rather than removing it, so "unset" consistently means "explicitly off"
rather than "back to default".

Fixes charmbracelet#194
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.

Setting BorderTop(false) disappears entire border

1 participant