maui icon indicating copy to clipboard operation
maui copied to clipboard

ScrollBarVisibility "Always" is not consistent.

Open PrestigiousF opened this issue 2 years ago • 10 comments

Description

I have my vertical scrollbar set to "Always". When the page is loaded, the scrollbar is there. Only AFTER I scroll in the scrollview, the scrollbar is visible, but then disappears when idle.

Steps to Reproduce

<ScrollView HeightRequest="130"
VerticalScrollBarVisibility="Always">
        <Label Text="{Binding Description}"
        Margin="0,0,0,16"/>
</ScrollView>

Link to public reproduction project repository

N/A

Version with bug

6.0.312

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 12

Did you find any workaround?

No response

Relevant log output

No response

PrestigiousF avatar Jan 19 '23 04:01 PrestigiousF

On Android that appears to be behaving "correctly" as it maps to VerticalScrollBarEnabled.

To make the scrollbars truly visible all the time requires ScrollBarFadingEnabled to be false in the Android code. Changing the behavior of ScrollBarVisibility.Always would probably be considered a breaking change (despite its confusing name).

GalaxiaGuy avatar Jan 20 '23 17:01 GalaxiaGuy

@GalaxiaGuy you did some digging on this? Could you maybe add some links to the code for this?

My initial reaction was: hm, yeah that's how some platforms work. Like on iOS I don't think you can even get the scrollbars to stay visible or it's highly discouraged by Apple at least. But on Android it seems like we could, but maybe we're mapping it to the wrong property?

Or, the bug might be here that the naming is not really clear about what it actually does. As it seems for Android where we map it to it seems to be something that enables and disables scrolling regardless of content is overflowing or not rather than showing or hiding the actual scrollbars.

It might be a breaking change, but that doesn't mean that we need to keep a potential bug alive because of that 😄

jfversluis avatar Jan 23 '23 15:01 jfversluis

Hi @PrestigiousF. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Jan 23 '23 15:01 ghost

I'm not sure what is being requested by the bot... Just giving and update - I'm not sure how to implement the suggestion by @GalaxiaGuy , as it's not a option in Xaml, I'm fairly new to MAUI.

PrestigiousF avatar Jan 24 '23 17:01 PrestigiousF

@jfversluis My research was mainly this stackoverflow post:

https://stackoverflow.com/questions/5702502/how-to-always-show-scrollbar

It boils down to disabling the fade using setScrollbarFadingEnabled(false) or setScrollBarFadeDuration(0) (while also doing the existing thing of enabling them even if the content doesn't scroll).

@PrestigiousF This functionality is only available in the native Android code, and some work would be need to expose it. There is a pretty in depth guide here:

https://learn.microsoft.com/en-us/dotnet/maui/user-interface/handlers/customize?view=net-maui-7.0

Although based on the comments by @jfversluis the current behavior of Always may be changed to anyway.

GalaxiaGuy avatar Jan 26 '23 08:01 GalaxiaGuy

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Jan 26 '23 19:01 ghost

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on android platform with sample code. 12760

Zhanglirong-Winnie avatar Jun 30 '23 08:06 Zhanglirong-Winnie

https://developer.android.com/reference/android/view/View#setScrollbarFadingEnabled(boolean) is inherited by ScrollViw on Android. Setting it has worked for renderers for me on Xamarin.Forms (and now on MAUI).

gkarabin avatar Aug 07 '23 20:08 gkarabin

Curiously, it doesn't seem to work when appending to a handler mapping, e.g.

            Microsoft.Maui.Handlers.ScrollViewHandler.Mapper.AppendToMapping("ObviousScrollViewCustomization",
                (handler, view) => {
                        handler.PlatformView.ScrollbarFadingEnabled = false;
                });

I'll keep poking at it.

gkarabin avatar Aug 07 '23 21:08 gkarabin

Curiously, it doesn't seem to work when appending to a handler mapping, e.g.

            Microsoft.Maui.Handlers.ScrollViewHandler.Mapper.AppendToMapping("ObviousScrollViewCustomization",
                (handler, view) => {
                        handler.PlatformView.ScrollbarFadingEnabled = false;
                });

I'll keep poking at it.

Add "handler.PlatformView.ScrollBarFadeDuration = 0;" might be useful.

franklintw1122 avatar May 24 '24 09:05 franklintw1122

This default behavior is kinda annoying :/

Confirmed it's working with this handler mapping :

ScrollViewHandler.Mapper.AppendToMapping("ScrollViewFixScrollBar", static (handler, view) =>
{
    handler.PlatformView.ScrollbarFadingEnabled = false;
    handler.PlatformView.ScrollBarFadeDuration = 0;
});

dartasen avatar Nov 15 '24 20:11 dartasen