-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Fix: ActivityIndicator IsRunning ignores IsVisible when set to true #28983
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
base: main
Are you sure you want to change the base?
Conversation
<VerticalStackLayout VerticalOptions="Center" HorizontalOptions="Center">
<ActivityIndicator HorizontalOptions="Center" x:Name="busy">
<ActivityIndicator.Triggers>
<DataTrigger TargetType="ActivityIndicator"
Binding="{Binding Source={x:Reference isRunningSwitch}, Path=IsToggled}"
Value="True">
<Setter Property="IsRunning" Value="True" />
</DataTrigger>
<DataTrigger TargetType="ActivityIndicator"
Binding="{Binding Source={x:Reference isVisibleSwitch}, Path=IsToggled}"
Value="True">
<Setter Property="IsVisible" Value="True" />
</DataTrigger>
<DataTrigger TargetType="ActivityIndicator"
Binding="{Binding Source={x:Reference isRunningSwitch}, Path=IsToggled}"
Value="False">
<Setter Property="IsRunning" Value="False" />
</DataTrigger>
<DataTrigger TargetType="ActivityIndicator"
Binding="{Binding Source={x:Reference isVisibleSwitch}, Path=IsToggled}"
Value="False"> <Setter Property="IsVisible" Value="False" />
</DataTrigger>
</ActivityIndicator.Triggers>
</ActivityIndicator>
<Switch x:Name="isRunningSwitch" HorizontalOptions="Center" />
<Label Text="Toggle IsRunning" HorizontalOptions="Center" />
<Switch x:Name="isVisibleSwitch" IsToggled="True" HorizontalOptions="Center" />
<Label Text="Toggle IsVisible" HorizontalOptions="Center" />
</VerticalStackLayout> |
jsuarezruiz
left a comment
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.
Could you include a Device Test for iOS checking the IsAnimating property of the UIActivityIndicatorView using the ActivityIndicator IsRunning and IsVisible properties? https://github.com/dotnet/maui/blob/ef1ec07908eda7b7bf9979fbbf9c374fbe7f2acf/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.iOS.cs
|
Thanks a lot for this PR! I just wanted to ask if you also tried using Thanks for your time. 😀 |
|
@Domik234 As I mentioned. |
|
@bhavanesh2001 Sorry, I was hasty. I was re-reading if I didn't missed and before I was able to edit, you answered. 😀 |
src/Core/src/Handlers/ActivityIndicator/ActivityIndicatorHandler.cs
Outdated
Show resolved
Hide resolved
|
@jfversluis Could you run pipelines. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| public partial class ActivityIndicatorHandlerTests : CoreHandlerTestBase<ActivityIndicatorHandler, ActivityIndicatorStub> | ||
| { | ||
| #if !WINDOWS // On Windows, the platform control will return IsActive as true even when the control is not visible. | ||
| [Theory(DisplayName = "IsRunning Should Respect IsVisible")] |
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.
Everything works as expected . But GetNativeIsRunning() seems to return true even when control is not visible. The UI test already covers this scenario.
Screen.Recording.2025-04-17.082414.mp4
|
@bhavanesh2001 , Adding the fix in the below places appears to resolve the issue with minimal code changes. Do you think more code changes are necessary? |
I think It's necessary to map and handle Visiibility like I did in the PR changes #if __ANDROID__ || IOS || MACCATALYST
// Since Visibility and IsRunning are dependent on each other, we handle Visibility explicitly.
[nameof(IActivityIndicator.Visibility)] = MapIsRunning,
#endifBased on the above changes, I think if I initialize the You can test and experiment with |
Yes @bhavanesh2001 , the mentioned scenario is working fine with my fix. The StartAnimate method is being called from the LayoutSubviews ActivityIndicatorDemo.mov |
|
@devanathan-vaithiyanathan I think with my changes, we can remove the animation logic from |
|
/rebase |
ff75339 to
f10320d
Compare
|
@bhavanesh2001 Will this be addressed in .NET 9, or is it planned for .NET 10? |
@jingo0 I'm not sure, But if you're facing an issue due to this, you can easily work your way around it. You can bind |
Binding IsRunning to IsVisible property did the trick. Surprisingly this issue only occurs on few Views! |
|
Thanks for the patch — any update on merge status or further changes needed to get this landed? @jsuarezruiz @StephaneDelcroix |
|
@jfversluis I think this is all done, just review is needed. Any chance this could be in next SR for MAUI? |
|
/rebase |
f10320d to
85943e4
Compare


Description of Change
On iOS, the
ActivityIndicatorbecomes visible even whenIsVisible = falseandIsRunning = true, effectively ignoring theIsVisibleproperty.Root Cause
Visibility is not being correctly mapped in iOS.
By default,
IsVisibleistruefor all elements, so we must explicitly manage visibility based on theIsRunningvalue — especially since it's expected that theActivityIndicatoris hidden by default.The current implementation seems to work because
IsRunningdefaults tofalse, which callsStopAnimating()and hides the native control. However, ifHidesWhenStoppedis set tofalse, the control remains visible without animating — which is incorrect.To fix this, we explicitly update the visibility inside the
IsRunningmapper, just as it's done on Android.before_fix.mov
after_fix.mov
Issues Fixed
Closes #28968