Fix ComposePanel
focus traversal on windows with nvda (Windows)
#1363
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ComposePanel
keeps its own_isFocusable
and_isRequestFocusEnabled
flags, and doesn't call the superclass' methods onsetFocusable
andsetRequestFocusEnabled
. Unfortunately Swing is not a well-behaved object-oriented library, and calling the superclass' methods has side effects which are needed.Component.setFocusable
sets anisFocusTraversableOverridden
flag which is consulted when determining the "next" focusable component (seeDefaultFocusTraversalPolicy.accept()
). This flag's value is, by default,FOCUS_TRAVERSABLE_UNKNOWN
, causingisFocusTraversableOverridden()
to returntrue
, which causes theComposePanel
to be accepted byDefaultFocusTraversalPolicy.accept()
.When NVDA is turned on, however, the accessibility system calls
ComposePanel.isFocusTraversable
, which sets this flag toFOCUS_TRAVERSABLE_DEFAULT
, causingisFocusTraversableOverridden()
to returnfalse
, which causesDefaultFocusTraversalPolicy.accept()
to reject theComposePanel
. IfComponent.setFocusable
has been called before that, this doesn't happen because the flag is set with:An alternative solution here would be for
ComposePanel
to overrideisFocusTraversable
in addition toisFocusable
, thus preventing theisFocusTraversableOverridden
from being set. This would be a less disruptive change, but I think the more correct way is to call the superclass' methods, as they have additional side effects (setFocusable
fires a property change, for example).Fixes https://youtrack.jetbrains.com/issue/COMPOSE-1398/Make-ComposePanel-transparent-to-accessibility
Testing
Run the app below on Windows, with NVDA turned on, and try traversing the buttons using (ctrl)-shift-tab.
Before this PR, the focus would jump only between the Swing buttons. After it, it will correctly go onto the Compose Button.
This could be tested by QA
Release Notes
Fixes - Desktop
ComposePanel
inside a Swing application on Windows with NVDA turned on, focus will now correctly go into theComposePanel
when traversing with (ctrl)-shift-tab.