Skip to content

Commit

Permalink
Accessibility: Moved Component::isCurrentlyBlockedByAnotherModalCompo…
Browse files Browse the repository at this point in the history
…nent() check into AccessibilityHandler::getCurrentState() to determine whether handler is considered focusable and removed Component::inputAttemptWhenModal() call

This prevents components from taking focus when they are blocked by another modal component by excluding them from the list of child handlers returned by AccessibilityHandler::getChildren() and fixes an issue with modal components being dismissed by handlers.
  • Loading branch information
ed95 committed Jun 14, 2021
1 parent 4c133c2 commit 928cc5f
Showing 1 changed file with 7 additions and 12 deletions.
Expand Up @@ -74,7 +74,10 @@ AccessibilityHandler::~AccessibilityHandler()
//==============================================================================
AccessibleState AccessibilityHandler::getCurrentState() const
{
auto state = AccessibleState().withFocusable();
AccessibleState state;

if (! component.isCurrentlyBlockedByAnotherModalComponent())
state = state.withFocusable();

return hasFocus (false) ? state.withFocused() : state;
}
Expand Down Expand Up @@ -210,7 +213,7 @@ std::vector<AccessibilityHandler*> AccessibilityHandler::getChildren() const

if (auto* handler = findEnclosingHandler (focusableComponent))
{
if (! isParentOf (handler))
if (! handler->getCurrentState().isFocusable() || ! isParentOf (handler))
return;

if (auto* unignored = getFirstUnignoredDescendant (handler))
Expand Down Expand Up @@ -283,16 +286,8 @@ void AccessibilityHandler::grabFocusInternal (bool canTryParent)
{
if (getCurrentState().isFocusable() && ! isIgnored())
{
const auto blockedByModal = component.isCurrentlyBlockedByAnotherModalComponent();

if (blockedByModal)
Component::getCurrentlyModalComponent()->inputAttemptWhenModal();

if (! blockedByModal || ! component.isCurrentlyBlockedByAnotherModalComponent())
{
takeFocus();
return;
}
takeFocus();
return;
}

if (isParentOf (currentlyFocusedHandler))
Expand Down

0 comments on commit 928cc5f

Please sign in to comment.