-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Android] Fixed the ScrollbarVisibility issues #27613
base: main
Are you sure you want to change the base?
Conversation
Hey there @Ahamed-Ali! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/Core/src/Platform/Android/MauiScrollView.cs:72
- [nitpick] The variable name
_verticalScrollVisibility
should not be prefixed with an underscore as it is not a private field. Consider renaming it toverticalScrollVisibility
.
ScrollBarVisibility _verticalScrollVisibility = scrollBarVisibility;
if (_defaultVerticalScrollVisibility == 0) | ||
_defaultVerticalScrollVisibility = VerticalScrollBarEnabled ? ScrollBarVisibility.Always : ScrollBarVisibility.Never; | ||
|
||
if (scrollBarVisibility == ScrollBarVisibility.Default) | ||
scrollBarVisibility = _defaultVerticalScrollVisibility; | ||
|
||
VerticalScrollBarEnabled = scrollBarVisibility == ScrollBarVisibility.Always; | ||
|
||
this.HandleScrollBarVisibilityChange(); | ||
ScrollbarFadingEnabled = _verticalScrollVisibility != ScrollBarVisibility.Always; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the HandleScrollBarVisibilityChange
method and the addition of PlatformInterop.RequestLayoutIfNeeded
could potentially be a breaking change. Please ensure this change is documented and communicated appropriately.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Root Cause of the issue
Initial Case:
ScrollBarFadingEnabled
property is always set to true even whenScrollBarVisibility
is set toAlways
. As a result, the scrollbar remains hidden in the Always visibility mode.Dynamic Case:
After fixing the initial issue, it was observed that when the visibility mode changes dynamically from
Default
toAlways
, the scrollbar does not display correctly. AlthoughScrollBarFadingEnabled
is updated properly, the scrollbar remains hidden because the HandleScrollBarVisibilityChange method processes both its true and false states, and RequestLayout is not called.In the native Android itself, dynamic changes to
ScrollbarFadingEnabled
are not properly reflected in the UI until the view is scrolled. CallingRequestLayout
when dynamic changes occur ensures that the native UI updates correctly.Description of Change
Initial Case:
ScrollBarFadingEnabled
based on ScrollBarVisibility resolves the issue.Dynamic Case:
RequestLayoutIfNeeded
efficiently resolves the dynamic issues and ensures that the UI updates properly. With RequestLayoutIfNeeded, calling AwakenScrollBars may no longer be necessary.Issues Fixed
Fixes #24894
Fixes #12760
Tested the behaviour in the following platforms
Screenshot
VerticalScrollbarVisibility
VerticalScrollBarIssue.mov
VerticalScrollbarFix.mov
HorizontalScrollbarVisibility
HorizontalScrollbarIssue.mov
HorizontalScrollbarFix.mov