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

[Android] Fixed the ScrollbarVisibility issues #27613

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Ahamed-Ali
Copy link
Contributor

@Ahamed-Ali Ahamed-Ali commented Feb 6, 2025

Root Cause of the issue

Initial Case:

  • The ScrollBarFadingEnabled property is always set to true even when ScrollBarVisibility is set to Always. 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 to Always, the scrollbar does not display correctly. Although ScrollBarFadingEnabled 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. Calling RequestLayout when dynamic changes occur ensures that the native UI updates correctly.

Description of Change

Initial Case:

  • Setting ScrollBarFadingEnabled based on ScrollBarVisibility resolves the issue.

Dynamic Case:

  • Removing the HandleScrollBarVisibilityChange method which was responsible for awakening the scrollbars and adding a call to 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

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

VerticalScrollbarVisibility

Before Issue Fix After Issue Fix
VerticalScrollBarIssue.mov
VerticalScrollbarFix.mov

HorizontalScrollbarVisibility

Before Issue Fix After Issue Fix
HorizontalScrollbarIssue.mov
HorizontalScrollbarFix.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 6, 2025
Copy link
Contributor

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.

@karthikraja-arumugam karthikraja-arumugam added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Feb 7, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Ahamed-Ali Ahamed-Ali marked this pull request as ready for review February 7, 2025 12:27
@Copilot Copilot bot review requested due to automatic review settings February 7, 2025 12:27
@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner February 7, 2025 12:27
Copy link
Contributor

@Copilot Copilot AI left a 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 to verticalScrollVisibility.
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;
Copy link
Preview

Copilot AI Feb 7, 2025

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.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@PureWeen PureWeen added this to the .NET 9 SR5 milestone Feb 7, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-scrollview ScrollView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android 🤖
Projects
Status: Ready To Review
4 participants