Skip to content

Filled Text Box hint position #3174

Closed

Description

@tanguyhardion

Bug explanation

The hint of the filled text box doesn't seem to be in the right position:

image
image

For reference, here is an outlined text box with the same code, which has the right alignment:

image

My code:

<TextBox Style="{StaticResource MaterialDesignFilledTextBox}"
                             materialDesign:HintAssist.Hint="Path"
                             materialDesign:HintAssist.IsFloating="True"
                             materialDesign:TextFieldAssist.HasLeadingIcon="True"
                             materialDesign:TextFieldAssist.LeadingIcon="DatabaseOutline"
                             Margin="15 0 0 0"
                             FontSize="15"
                             Padding="12 8"
                             Height="56"
                             Foreground="{DynamicResource OnBackground}" />

I tried using TextBoxViewMargin but without much success.

Version

4.8.0

Activity

  1. added
    evaluation required
    on Apr 25, 2023
  2. nicolaihenriksen commented on Apr 25, 2023

    @nicolaihenriksen
    Contributor

    @tanguyhardion I just had a brief look at this. The TextBox styles in MDIX seem to have been designed for "their default size". This means that when you start modifying things like Padding, FontSize, and Height (in particular), the hint and icon placements are affected in ways that do not always look good. I have tested your code going all the way back to version 4.0.0 where the leading icon was introduced, and all versions have (different) issues.

    There has recently been done some work refactoring the SmartHint and the placement of it. Some of that is not yet released, but even on the latest (not released) code, there are still issues when using the code you provided. When I have some time, I will look into adding a bit better support for things like this, although I believe it will be difficult to land a solution that works perfectly in all scenarios.

  3. removed
    evaluation required
    on Apr 25, 2023
  4. added this to the 4.9.0 milestone on Apr 27, 2023
  5. nicolaihenriksen commented on May 11, 2023

    @nicolaihenriksen
    Contributor

    @tanguyhardion In the code you provided, you are explicitly setting FontSize. This is one of the remaining issues that I did not tackle 100% in the PR that was merged. You may run into issues with it, especially if you combine it with Height and VerticalContentAlignment properties.

    If you do use some custom values, you can always play around with setting a custom HintAssist.FloatingOffset as well. This will allow you full control of the (relative) placement of the floated hint. The default is (0,-16) I believe, and this is a special value which receives special handling. So if you want custom handling, you need to set it to something different. In the rare case that you actually need it to be manually positioned at (0,-16) you can probably just set the value to (0, -16.001) or something like that to avoid the "special handling case"; This is a side-effect of a somewhat unfortunate default value of the DP in my opinion, but there are probably reasons for it being the way it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions