Focusing a text input causes elements underneath to shift down
Describe the bug
When a TextBox is focused, the height of the TextBox grows by 1px, pushing down every element below it .
https://github.com/user-attachments/assets/e23c767c-c50c-4c18-b810-7ef0899695cf
Elements affected:
- TextBox
- PasswordBox
Elements not affected:
- RichEditBox
- AutoSuggestBox
- ComboBox
- NumberBox (It happens in the gallery for some reason, but not in apps)
Reproduction
- Open the Gallery app
- Go to the TextBox page
- Focus and and unfocus a TextBox
Suggested Solution
After comparing the differences between the controls which have the problem and those which don't, I found a fix.
The cause
In the TextBox element, the margin of both the ScrollViewerEx and the TextBlock are linked to {TemplateBinding BorderThickness}
https://github.com/iNKORE-NET/UI.WPF.Modern/blob/e71bed9b67090ee4ccddd019e68100296f84770f/source/iNKORE.UI.WPF.Modern/Themes/Controls/TextBox.xaml#L234-L240
When the TextBox is focused, the BorderThickness is increased for both elements. This is fine for the ElevationBorder as it doesn't affect the height of the TextBox, but the margins do. The increasing margins of the ScrollViewerEx and TextBlock are causing the height of the TextBox to increase.
The fix
Use what is done for all the elements not affected by the issue: https://github.com/iNKORE-NET/UI.WPF.Modern/blob/e71bed9b67090ee4ccddd019e68100296f84770f/source/iNKORE.UI.WPF.Modern/Themes/Controls/RichTextBox.xaml#L111-L117
By using <Setter TargetName="BorderElement" Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThicknessFocused}" />, you target specifically the BorderElement and avoid affecting the button.
Lines to change:
Library Version
0.10.1
Operating System
Windows 11
Framework
.NET Core and .NET
Framework Version
9
Source of Package
NuGet.org (Package)
Additional Notes
No response
Validations
- [x] Check that there isn't already an issue that reports the same or similar problem.
- [x] Check that this is a bug in the library that should be fixed, not a feature, also this is not about the documentation. (Or please choose the right repo and template.)
- [x] This is one single problem, or a few problems with the same cause. (If you want to report multiple problems, please create one issue for every single problem.)
- [x] You've checked that this problem still exists in the latest version. (Keep in mind that we don't provide any support for old versions.)
- [x] You know that we can't guarantee that we will satisfy your request. This is not really our duty to do everything anyone asks for. Also, you will treat our staff, contributors, and other users with respect and kindness.
- [x] You're sure there's something wrong with the library itself, not how you're using it. (If you are having issues using it and need help, please go to discussion.)