Skip to content

Caret Index is hidden when FlowDirection is RightToLeft On Material Design in C# WPF #2949

Closed

Description

@mojtabahakimian

Bug explanation

I'm using 4.6.1 version of MaterialDesing in .Netfreamwork

the CaretIndex On the TextBox doesn't show until I click on the text box again, and the interesting thing is that if the text box is empty, the Caret Index is slightly out of the frame and a little unclear.

Full description with code and photo : https://stackoverflow.com/questions/74441792/caret-index-is-hidden-when-flowdirection-is-righttoleft-on-material-design-in-c

This problem does not exist in this 3.2.0 version

Version

4.6.1

Activity

  1. nicolaihenriksen commented on Nov 18, 2022

    @nicolaihenriksen
    Contributor

    @mojtabahakimian None of the provided links are working 😢

    I am curious whether the problem you see is the same as #2865 which unfortunately I have not been able to reproduce. If you can provide a small sample that illustrates the issue that would be great.

  2. Keboo commented on Nov 19, 2022

    @Keboo
    Member

    I fixed the links above to point to the correct urls

  3. mojtabahakimian commented on Nov 19, 2022

    @mojtabahakimian
    Author

    Thanks for fixing ... , those links are ok now and here is my full code that created on Visua Studio 2019 with .NetFreamwork 4.7.2

    you can see problem in this source
    Link:

    https://mega.nz/file/Y4wDXA7Q#t-UJFd-Dik8CJqNjDVQcWXhb4SoF5tZEHDLYenfmeLo

  4. mojtabahakimian commented on Nov 19, 2022

    @mojtabahakimian
    Author

    Interestingly, this previous version 3.2.0 does not have this caret problem for right to left

    but after that version until current version This problem still exists

  5. nicolaihenriksen commented on Nov 19, 2022

    @nicolaihenriksen
    Contributor

    @mojtabahakimian @Keboo Thanks for the updates 👍

    Funny observation. I am typically on 4K monitors using 150% scaling. In that setup I am unable to reproduce the issue using your sample solution:
    WithScaling

    However, when I set the scaling to 100% (i.e. turn off scaling), then I can reproduce it:
    WithoutScaling
    -- Note that the IBeam is not visible in the RTL TextBox in this recording.

    I noted a similar visual artifact when adding the "reveal styles" for PasswordBox; see the last part of the description in this PR: #2828

    I will dig further into it when I have some time.

  6. nicolaihenriksen commented on Nov 19, 2022

    @nicolaihenriksen
    Contributor

    @Keboo @mojtabahakimian Forget my previous comment if you read it (I have deleted it). I had a little time this evening, so I tracked down the root cause I believe.

    The base style for a MDIX TextBox has the following setter inside a trigger for TextFieldAssist.HasFilledTextField=True (and outlined style as well):

    <Setter Property="wpf:TextFieldAssist.TextBoxViewMargin" Value="{x:Static wpf:Constants.DefaultTextBoxViewMarginEmbedded}" />

    The property being set here (TextFieldAssist.TextBoxViewMargin), is only explicitly used to set a margin on the hint text (if present). However, setting the property, invokes a callback which also sets the provided Thickness on the Part_ContentHost of the template. This is done in TextFieldAssist.ApplyTextBoxViewMargin(Control, Thickness).

    A proposed fix for the issue is to not set the attached property on the TextBox, but rather target the "hint" element directly:

    <Setter TargetName="Hint" Property="wpf:TextFieldAssist.TextBoxViewMargin" Value="{x:Static wpf:Constants.DefaultTextBoxViewMarginEmbedded}" />

    This is of course a slight change in the Margin of the PART_ContentHost, but also what I believe to be the root cause of the issue. @Keboo I will create a PR with the change, then you can evaluate it.

  7. removed
    Waiting on feedbackAdditional information is needed. Stale items with this label may be closed.
    evaluation requiredItems is pending review or evaluation by the team
    on Nov 19, 2022
  8. added this to the 4.7.0 milestone on Nov 24, 2022
  9. mojtabahakimian commented on Dec 6, 2022

    @mojtabahakimian
    Author

    May I ask you to give me a full example code that fixing the caret problem ?

  10. nicolaihenriksen commented on Dec 6, 2022

    @nicolaihenriksen
    Contributor

    May I ask you to give me a full example code that fixing the caret problem ?

    You should be able to pull the latest nightly build from nuget.org and verify that it fixes the issue. It would actually be good to know if you also consider the issue fixed with the changes in PR #2958.

    I was able to reproduce the issue, and those changes solved the issue in my reproduction sample. Let me know if your issue is also solved with the changes.

  11. mojtabahakimian commented on Dec 8, 2022

    @mojtabahakimian
    Author

    hi please check it out this :
    Untitled

  12. mojtabahakimian commented on Dec 8, 2022

    @mojtabahakimian
    Author

    still caret issue for the MaterialDesignOutlinedTextBox

  13. nicolaihenriksen commented on Dec 8, 2022

    @nicolaihenriksen
    Contributor

    @mojtabahakimian Are you sure you've updated to one of the latest pre-releases (nightly releases)? I just tested with the latest nightly build (4.7.0-ci385) and the sample project you added to this issue. With that, I am unable to reproduce the issue for any of the MDIX TextBox styles (MaterialDesignOutlinedTextBox, MaterialDesignFilledTextBox, MaterialDesignFloatingHintTextBox). I tested both 100% scaling and 150% scaling.

    image

    image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions