-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix TextBox horizontal scrollbar position when VerticalContentAlignment is set to Top
#3931
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
Fix TextBox horizontal scrollbar position when VerticalContentAlignment is set to Top
#3931
Conversation
|
It seems the failing test In fact, my PR is very much doing the same thing as #3162, the PR fixing #3161. Looks like I missed the Let me know if you want this handled in another way. |
934ab0a to
71b4562
Compare
|
/cc @nicolaihenriksen, the author of both #3162 and #3486. |
71b4562 to
1175e39
Compare
|
@database64128 The fact that the horizontal scrollbar in some cases was not anchored at the bottom is definitely a bug, no discussion! Good catch and thanks for fixing it. (edit: not entirely sure this was actually a bug at all anymore, possibly more an accepted side-effect of the change. See my comments below for details).
This was very much an intentional change, because there are SO MANY different configurations that you can use the So when making changes like you have, changing the default position of the hint, please ensure that you check all the various combinations with As a sidenote, |
|
@database64128 I have just tested your branch, and as I suspected, the
The test is not obsolete (running green on main branch), your changes do indeed cause the regression (particularly because of the use of fixed height). I am afraid that this change breaks more than it fixes. |
|
@database64128 After reading your description thoroughly again, I believe that for your particular use-case, the only change you would need in your app, is to add Or am I missing something obvious? |
I did try that. With just This is the current (and expected) look when the log viewer is empty:
This is with just
I actually just shipped a new release with the broken horizontal scrollbar position, because the first screenshot looked so much better than the second. The log viewer in question: https://github.com/database64128/youtube-dl-wpf/blob/aea8d298dc36a6190660573a828bffaa55d98721/YoutubeDl.Wpf/Views/HomeView.xaml#L411-L421 |
|
@database64128 But if you want the hint (and icons etc.) to rest at the top, you definitely should set So apparently, I still don't fully grasp the issue you're facing 🤔 |
|
@database64128 That definitely looks like a bug. However, I think the changes in this PR breaks a lot of other stuff, so let me see if I can work out a way to fix it without causing a regression. Do you have a fixed height set on the |
Thanks. It's the latter. The log viewer is on a row with |
1175e39 to
b824a61
Compare
Edit: Nevermind, it's still broken in some combinations. |
b824a61 to
e36bfd9
Compare
e36bfd9 to
0f80270
Compare
|
OK, I think I have finally fixed it. There are some minor behavioral differences in multi-line text boxes compared to the main branch:
I also un-obsoleted @nicolaihenriksen Can you please take a look? |
I'm aware the test is still passing on the main branch. By obsolete, I meant that the test was no longer testing what it claims to be testing. The |
|
@database64128 I have now pushed a branch called textBoxHorizScrollBarIssue which potentially solves the issue using my approach described above. Could you pull in this branch and see if it solves your particular issue? I will need approval from the primary maintainer (@Keboo) for a change like this. If it solves your issue, I'll create a PR and have him review it. |
The
Oh it will not hide the icons, prefix/suffix or the clear button. My point is that the scrollbar is something "native" to the TextBox, so (to me) it feels weird to have it not fill the width just because we decided to decorate the control with a little extra elements. Even though it now fills the entire width, it still only scrolls the text. |
Played around for a bit:
|
|
@database64128 Hmm... Interesting. I think that is a timing issue, and I was maybe a bit bold simply placing a bang there. Apparently the UPDATE: Same problem for |
Thanks for the explanation! Your point definitely also makes sense! I don't have strong feelings about this, as I don't have any use case where the horizontal scroll bar is enabled together with icons or prefix/suffix text. |
|
@database64128 I have pushed two null-guard checks and an invocation of As I cannot currently reproduce the crash, would you mind checking if the invocation is in fact needed or not? Thanks. |
|
@database64128 Thank you. Yeah the dual-scrollbar issue I need to address. In fact once I simply get the correct (dynamic) margin I think the new approach will look better than the old where WPF has this weird thing with placing a white rectangle in the corner where the scrollbars meet. Anyway, I will look into fixing that part. Regarding your performance concerns, I also have my concerns. However it is only a single extra control ( |
|
@database64128 Hmm... Maybe I am changing my mind on the "full width horiz scrollbar" idea. Because with your use case where both are visible, things become really ugly when combined with other elements (icons, buttons, etc.)
I think I will pull it back in to only fill the width of the actual |
|
@database64128 I have now pushed the changes to pull the custom horizontal scrollbar back into where the original horiz-scrollbar was placed. Hopefully that gives a better look for your use case?
|
|
@nicolaihenriksen With 6b40aa2:
The horizontal scrollbar is still off, and still moves a little when the Also you forgot to remove the null-forgiving operator in |
|
@database64128 Thanks again 😆 I have a hunch I know what is happening. I think it is taking icon- and prefixtext-margins into account even in the case where they are not visible. I'll fix this and push another update. UPDATE: And good catch on the focus transition. That is because of the width of the border changing... That I also need to take into account 🤔 |
|
@database64128 Pushed 2 more commits. Cleanup of (hopefully the last remaining 😆) null-forgiving operators, and another commit which correctly deals with margins/visibility/hover-state/keyboard-focus; at least that is what I hope it does. It looks pretty good on my PC even though I am running a 150% DPI scaling so there may be some things that are slightly off. I did check with 100% as well, but I have been surprised before where there is a slight difference using other peoples setup (typically where DPI scaling is not at all in use) in contrast to mine. I do have an office setup without DPI scaling, but I am currently not in the office... |
|
@nicolaihenriksen Thanks! With the latest commit, everything now looks good for my use case. However, the horizontal scrollbar still moves around in the non-outlined variants:
Same here, let me guess, is it a 27-inch 4K monitor? 😄 |
|
@database64128 Haha, I knew there was something I had forgotten; compensation only needed for outlined style 😂 I'll fix that and create both an issue and a corresponding PR with my changes. Then we'll see what @Keboo thinks of it. |
|
@database64128 Don't recall the actual size, but yes a 4K monitor 👍 |


















Will most likely be replaced by PR #3934.
Since #3486, if you have
VerticalContentAlignment="Top"set on aTextBox, the horizontal scrollbar will not be at the bottom of theTextBox.I'm demonstrating this bug by making some changes to the first outlined TextBox in the demo app:
VerticalContentAlignment="Top"I'm keeping these changes in the PR, because the second textbox already has the content centered and text wrapping enabled. Let me know if you prefer keeping the first TextBox as-is.
Before the fix:
After the fix:
The fix is fairly straightforward.
VerticalContentAlignmentwas mistakenly bound toVerticalAlignment. TheScrollViewershould always stretch to fill the whole space.I also tested the fix with
VerticalContentAlignment="Bottom", and everything still looks as expected:For context, my app uses a
TextBoxto display logs. #3486 broke myTextBoxin 2 ways:AcceptsReturn="True", theTextBoxnow defaults to centering the text, which is certainly not what you want for displaying logs. I didn't haveAcceptsReturn="True"on myTextBoxbefore, because it already hasIsReadOnly="True". This is kind of a breaking change in behavior, but I'm OK with keeping it as-is.VerticalContentAlignment="Top", I encountered this exact bug, which this PR fixes.