Skip to content

Commit

Permalink
Merge pull request #5830 from Gillibald/fixes/TextBoxWrapWithoutAccep…
Browse files Browse the repository at this point in the history
…tsReturn

Fixes TextBox text wrap without accepts return
  • Loading branch information
Gillibald authored and danwalmsley committed Apr 30, 2021
1 parent a388849 commit a37ccee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/Avalonia.Controls/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,12 @@ public TextBox()
this.GetObservable(TextWrappingProperty),
(acceptsReturn, wrapping) =>
{
if (acceptsReturn)
if (wrapping != TextWrapping.NoWrap)
{
return wrapping != TextWrapping.Wrap ?
ScrollBarVisibility.Auto :
ScrollBarVisibility.Disabled;
}
else
{
return ScrollBarVisibility.Hidden;
return ScrollBarVisibility.Disabled;
}
return acceptsReturn ? ScrollBarVisibility.Auto : ScrollBarVisibility.Hidden;
});
this.Bind(
ScrollViewer.HorizontalScrollBarVisibilityProperty,
Expand Down
2 changes: 1 addition & 1 deletion tests/Avalonia.Controls.UnitTests/TextBoxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public void Press_Enter_Add_Custom_Newline()

[Theory]
[InlineData(new object[] { false, TextWrapping.NoWrap, ScrollBarVisibility.Hidden })]
[InlineData(new object[] { false, TextWrapping.Wrap, ScrollBarVisibility.Hidden })]
[InlineData(new object[] { false, TextWrapping.Wrap, ScrollBarVisibility.Disabled })]
[InlineData(new object[] { true, TextWrapping.NoWrap, ScrollBarVisibility.Auto })]
[InlineData(new object[] { true, TextWrapping.Wrap, ScrollBarVisibility.Disabled })]
public void Has_Correct_Horizontal_ScrollBar_Visibility(
Expand Down

0 comments on commit a37ccee

Please sign in to comment.