fix: disabling one border side no longer hides all sides - #696
Open
troclaux wants to merge 1 commit into
Open
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
applyBorderdefaulted every unset side key tofalse, then relied onisBorderStyleSetWithoutSides()to flip them totruewhen no side key was present. That helper returnsfalsethe moment any side key exists — even one explicitly set tofalse— so callingBorderTop(false)caused all remaining sides to vanish.Fix
borders.go: usedefaultSide := border != noBorderso each unset side inheritstruewhenever a border style is active. The now-redundantisBorderStyleSetWithoutSides()block inapplyBorderis removed.unset.go: changeUnsetBorder{Top,Right,Bottom,Left}to callBorderSide(false)(keeps the key in props asfalse) rather than removing the key, so "unset" consistently means "explicitly off" rather than "removed from props."Before / after