Skip to content

Commit

Permalink
Fix accessibility on underlying popups
Browse files Browse the repository at this point in the history
  • Loading branch information
IeuanWalker authored Sep 12, 2024
1 parent ef3d3c3 commit cea156e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Mopups/Mopups.Maui/Platforms/Android/Impl/AndroidMopups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,36 @@ void HandleAccessibility(bool showPopup, bool disableAccessibilityHandling, Popu
}

int navCount = mainPage.Navigation.NavigationStack.Count;
int modalCount = mainPage.Navigation.ModalStack.Count;

if(navCount > 0)
{
var androidView = mainPage.Navigation?.NavigationStack[navCount - 1]?.Handler?.PlatformView as Android.Views.View;
var androidView = mainPage.Navigation.NavigationStack[navCount - 1]?.Handler?.PlatformView as Android.Views.View;

if(androidView is not null && androidView.ImportantForAccessibility != ImportantForAccessibility.NoHideDescendants)
{
views.Add(androidView);
}
}

int modalCount = mainPage.Navigation.ModalStack.Count;
if(modalCount > 0)
{
var androidView = mainPage.Navigation?.ModalStack[modalCount - 1]?.Handler?.PlatformView as Android.Views.View;
var androidView = mainPage.Navigation.ModalStack[modalCount - 1]?.Handler?.PlatformView as Android.Views.View;
if(androidView is not null && androidView.ImportantForAccessibility != ImportantForAccessibility.NoHideDescendants)
{
views.Add(androidView);
}
}

var test = popup.GetType();
var popupCount = MopupService.Instance.PopupStack.Count;
if(popupCount > 1)
{
var androidView = MopupService.Instance.PopupStack[popupCount - 2]?.Handler?.PlatformView as Android.Views.View;
if(androidView is not null && androidView.ImportantForAccessibility != ImportantForAccessibility.NoHideDescendants)
{
views.Add(androidView);
}
}

accessibilityStates.Add(test, views);
}

Expand Down Expand Up @@ -163,4 +171,4 @@ static Task<bool> PostAsync(Android.Views.View? nativeView)

return tcs.Task;
}
}
}

0 comments on commit cea156e

Please sign in to comment.