Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hint does not being repositioned to the top left corner if the textbox has preconfigured text #3636

Open
bardur1234 opened this issue Jul 20, 2024 · 7 comments
Labels
bug evaluation required Items is pending review or evaluation by the team Waiting on feedback Additional information is needed. Stale items with this label may be closed.

Comments

@bardur1234
Copy link

Bug explanation

I upgraded recently to the latest version of Material Design and found out that hints in outlined textboxes are not moving up left side when the text is prepopulated (with Binding), when the presentation is showing. It works if there is no text and I am entering it.

I upgraded Material Design from version 4.9 to 5.1 and started experiencing the issue.

image

Version

5.1

@bardur1234 bardur1234 added bug evaluation required Items is pending review or evaluation by the team labels Jul 20, 2024
@nicolaihenriksen
Copy link
Contributor

nicolaihenriksen commented Jul 20, 2024

@bardur1234 I am unable to reproduce this issue (on the latest code at least). Can you share a bit of XAML so I can see if anything there could be causing this behavior.

With this XAML:

<TextBox Style="{StaticResource MaterialDesignOutlinedTextBox}"
         materialDesign:HintAssist.Hint="My hint"
         Text="{Binding TextFromViewModel}" />

I get this result.
image

I have tried: 1) setting a default value for ViewModel.TextFromViewModel, 2) setting a value set in the constructor, and 3) setting a value set after the Loaded event has fired in the UI. They all work as expected.

@nicolaihenriksen nicolaihenriksen added the Waiting on feedback Additional information is needed. Stale items with this label may be closed. label Jul 20, 2024
@bardur1234
Copy link
Author

bardur1234 commented Jul 20, 2024 via email

@nicolaihenriksen
Copy link
Contributor

nicolaihenriksen commented Jul 20, 2024

I downgraded to version 5.0 from 5.1 to check if the issue exists in that version and can confirm that with version 5.0 I didn't experience that issue.

So, version 5.1 did include a major refactoring of the SmartHint, especially regarding the placement of the hint. That could explain why you see the difference. But unfortunately I am still not able to reproduce it in any way, shape, or form.

The code you have pasted in the response above is taken quite a bit out of context, and is difficult for me to decipher anything from (it does not compile without other needed bits). I am however noticing your use of async/await in many places. I'll try a few other things down that path to see if I can reproduce the issue.

Simply wrapping the TextBox in a UserControl exposing a DependencyProperty for both the text and hint works fine for me.

A couple of things I noticed in your code:

  • You're overriding OnInitialized(), and in there you're calling InitializeComponent(). Is there a particular reason for this? The typical approach would be to have a default constructor which invokes InitializeComponent(). Manually calling it after the control indicates that is HAS BEEN initialized, seems like a wrong order...
  • Use of async/await is spread throughout the provided code, and some methods that return a Task, and have the async keyword in the method signature are not using the await keyword in the method body?! Does that code compile, as-is, on your side? Again, it seems to be taken out of context...
    • UPDATE: Nevermind this, I think I just have my analyzers set to mark this is an error instead of a warning. <TreatWarningsAsErrors>true</TreatWarningsAsErrors>

@nicolaihenriksen
Copy link
Contributor

@bardur1234 You wouldn't happen to be setting HintAssist.FloatingOffset explicitly in your code would you? If so, the value set will take precedence and basically opt-out of the automatically calculated floating offset.

@bardur1234
Copy link
Author

bardur1234 commented Jul 23, 2024 via email

Copy link
Contributor

This issue is marked stale because it has been open 30 days with no activity. Remove stale label or update the issue, otherwise it will be closed in 14 days.

@github-actions github-actions bot added the Stale Issues and PRs that have not had activity for a while are marked with this label. label Aug 23, 2024
@nicolaihenriksen nicolaihenriksen removed Waiting on feedback Additional information is needed. Stale items with this label may be closed. Stale Issues and PRs that have not had activity for a while are marked with this label. labels Aug 23, 2024
@nicolaihenriksen
Copy link
Contributor

@bardur1234 Would you be able to share some of your XAML, or possibly even a small demo repo with code that reproduces this? I am unable to reproduce it with the information given above.

@nicolaihenriksen nicolaihenriksen added the Waiting on feedback Additional information is needed. Stale items with this label may be closed. label Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug evaluation required Items is pending review or evaluation by the team Waiting on feedback Additional information is needed. Stale items with this label may be closed.
Projects
None yet
Development

No branches or pull requests

2 participants