Skip to content

Conversation

ASalavei
Copy link

@ASalavei ASalavei commented Jul 4, 2025

Change the accessibility focus to the most recently focused element.
Due to the complexity of implementation, it does not refocus on the same accessibility element that was already in focus. (Same behavior present on native iOS).

Fixes https://youtrack.jetbrains.com/issue/CMP-8272/Focus-change-with-VoiceOver-on-iOS-not-working

Release Notes

Fixes - iOS

  • Change the accessibility selection to the element that has most recently been focused on.

@ASalavei ASalavei requested review from svastven and mazunin-v-jb July 4, 2025 08:24
@ASalavei ASalavei requested a review from svastven July 4, 2025 09:44

if (forceFocusedElementKey != focusedElementKey) {
forceFocusedElementKey = focusedElementKey
focusedElementKey?.let {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is no focused elemet (focusedElementKey == null) don't we want to set the focuseMode to None here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we should keep the old value. The reason is that Compose Ficus and Accessibility focus are work in parallel.
forceFocusedElementKey represent focused element of the Compose, but focuseMode represent the focus of Accessibility (at least it tries).
The logic is the following: when Compose focuses some node, we have to move Accessibility focus to this place. If compose releases focus, we don't need to do anything and keep focus as it was before.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks for the explanation!

@ASalavei ASalavei requested a review from svastven July 4, 2025 11:33
@ASalavei ASalavei merged commit cadd65b into jb-main Jul 4, 2025
10 checks passed
@ASalavei ASalavei deleted the andrei.salavei/accessibility-focus branch July 4, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants